Skip to content

Commit

Permalink
Chore: update invariant messages (#479)
Browse files Browse the repository at this point in the history
* Chore: update docs

* Chore: update invariant messages
  • Loading branch information
Zyie committed Mar 20, 2024
1 parent 0e32df3 commit 004c816
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/components/AnimatedSprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const AnimatedSprite = (root, props) =>
{
invariant(
texture instanceof Texture || texture?.texture,
`AnimationSprite texture needs to be an array of \`PIXI.Texture\` or \`{ texture: PIXI.Texture, time:
`AnimationSprite texture needs to be an array of \`Texture\` or \`{ texture: Texture, time:
number }\``
);

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Graphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import invariant from '../utils/invariant';

const Graphics = (root, { geometry }) =>
{
invariant(!geometry || geometry instanceof PixiGraphics, `Graphics geometry needs to be a \`PIXI.Graphics\``);
invariant(!geometry || geometry instanceof PixiGraphics, `Graphics geometry needs to be a \`Graphics\``);
const g = geometry ? new PixiGraphics(geometry.geometry) : new PixiGraphics();

g.applyProps = (instance, oldProps, newProps) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/SimpleRope.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SimpleRope = (root, props) =>
{
const { image, texture, ...props } = newProps;

invariant(Array.isArray(newProps.points), 'SimpleRope points needs to be %s', 'Array<PIXI.Point>');
invariant(Array.isArray(newProps.points), 'SimpleRope points needs to be %s', 'Array<Point>');
let changed = applyDefaultProps(instance, oldProps, props);

if (image || texture)
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function useApp()
invariant(
app instanceof Application,
'No Context found with `%s`. Make sure to wrap component with `%s`',
'PIXI.Application',
'Application',
'AppProvider'
);

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useTick.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function useTick(callback, enabled = true)
invariant(
app instanceof Application,
'No Context found with `%s`. Make sure to wrap component with `%s`',
'PIXI.Application',
'Application',
'AppProvider'
);

Expand Down
9 changes: 4 additions & 5 deletions packages/react/src/reconciler/hostconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function removeChild(parent, child)

function insertBefore(parent, child, beforeChild)
{
invariant(child !== beforeChild, 'pixi-react: PixiFiber cannot insert node before itself');
invariant(child !== beforeChild, 'Cannot insert node before itself');

const childExists = parent.children.indexOf(child) !== -1;

Expand Down Expand Up @@ -258,10 +258,9 @@ const HostConfig = {
{
invariant(
false,
`pixi-react: Error trying to add text node "${text}"`,
'PixiFiber does not support text nodes as children of a Pixi component. '
+ 'To pass a string value to your component, use a property other than children. '
+ 'If you wish to display some text, you can use &lt;Text text={string} /&gt; instead.'
`Error trying to add text node "${text}"`,
'text strings as children of a Pixi component is not supported. '
+ 'To add some text, use &lt;Text text={string} /&gt;'
);
},

Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function unmountComponent(container)
{
invariant(
Container.prototype.isPrototypeOf(container),
'Invalid argument `container`, expected instance of `PIXI.Container`.'
'Invalid argument `container`, expected instance of `Container`.'
);

if (roots.has(container))
Expand All @@ -38,12 +38,12 @@ export function createRoot(container)
{
invariant(
Container.prototype.isPrototypeOf(container),
'Invalid argument `container`, expected instance of `PIXI.Container`.'
'Invalid argument `container`, expected instance of `Container`.'
);

let root = roots.get(container);

invariant(!root, 'Pixi React: createRoot should only be called once');
invariant(!root, 'createRoot should only be called once');

if (!root)
{
Expand Down
5 changes: 2 additions & 3 deletions packages/react/src/utils/pixi.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ export function setValue(instance, prop, value)

invariant(
typeof coordinates !== 'undefined' && coordinates.length > 0 && coordinates.length < 3,
'The property `%s` is a `PIXI.Point` or `PIXI.ObservablePoint` and must be set to a comma-separated string of '
+ 'either 1 or 2 coordinates, a 1 or 2 element array containing coordinates, or a PIXI Point/ObservablePoint. '
+ 'If only one coordinate is given then X and Y will be set to the provided value. Received: `%s` of type `%s`.',
'The property `%s` is a `Point` and must be set to a comma-separated string of '
+ 'either coordinates, an array containing coordinates, or a Point.',
prop,
JSON.stringify(value),
typeof value
Expand Down
4 changes: 2 additions & 2 deletions packages/react/test/hooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('hooks', () =>
});

expect(createApp).toThrow(
'No Context found with `PIXI.Application`. Make sure to wrap component with `AppProvider`'
'No Context found with `Application`. Make sure to wrap component with `AppProvider`'
);
});

Expand Down Expand Up @@ -91,7 +91,7 @@ describe('hooks', () =>
});

expect(createApp).toThrow(
'No Context found with `PIXI.Application`. Make sure to wrap component with `AppProvider`'
'No Context found with `Application`. Make sure to wrap component with `AppProvider`'
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react/test/render.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('render', () =>
test('invariant container', () =>
{
expect(() => render('something', null)).toThrow(
'Invalid argument `container`, expected instance of `PIXI.Container`'
'Invalid argument `container`, expected instance of `Container`'
);
});

Expand Down

0 comments on commit 004c816

Please sign in to comment.