Skip to content

Commit 004c816

Browse files
authored
Chore: update invariant messages (#479)
* Chore: update docs * Chore: update invariant messages
1 parent 0e32df3 commit 004c816

File tree

10 files changed

+17
-19
lines changed

10 files changed

+17
-19
lines changed

packages/react/src/components/AnimatedSprite.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const AnimatedSprite = (root, props) =>
1212
{
1313
invariant(
1414
texture instanceof Texture || texture?.texture,
15-
`AnimationSprite texture needs to be an array of \`PIXI.Texture\` or \`{ texture: PIXI.Texture, time:
15+
`AnimationSprite texture needs to be an array of \`Texture\` or \`{ texture: Texture, time:
1616
number }\``
1717
);
1818

packages/react/src/components/Graphics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import invariant from '../utils/invariant';
44

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

1010
g.applyProps = (instance, oldProps, newProps) =>

packages/react/src/components/SimpleRope.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const SimpleRope = (root, props) =>
1313
{
1414
const { image, texture, ...props } = newProps;
1515

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

1919
if (image || texture)

packages/react/src/hooks/useApp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function useApp()
1010
invariant(
1111
app instanceof Application,
1212
'No Context found with `%s`. Make sure to wrap component with `%s`',
13-
'PIXI.Application',
13+
'Application',
1414
'AppProvider'
1515
);
1616

packages/react/src/hooks/useTick.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function useTick(callback, enabled = true)
1111
invariant(
1212
app instanceof Application,
1313
'No Context found with `%s`. Make sure to wrap component with `%s`',
14-
'PIXI.Application',
14+
'Application',
1515
'AppProvider'
1616
);
1717

packages/react/src/reconciler/hostconfig.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function removeChild(parent, child)
101101

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

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

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

packages/react/src/render/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function unmountComponent(container)
1212
{
1313
invariant(
1414
Container.prototype.isPrototypeOf(container),
15-
'Invalid argument `container`, expected instance of `PIXI.Container`.'
15+
'Invalid argument `container`, expected instance of `Container`.'
1616
);
1717

1818
if (roots.has(container))
@@ -38,12 +38,12 @@ export function createRoot(container)
3838
{
3939
invariant(
4040
Container.prototype.isPrototypeOf(container),
41-
'Invalid argument `container`, expected instance of `PIXI.Container`.'
41+
'Invalid argument `container`, expected instance of `Container`.'
4242
);
4343

4444
let root = roots.get(container);
4545

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

4848
if (!root)
4949
{

packages/react/src/utils/pixi.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ export function setValue(instance, prop, value)
138138

139139
invariant(
140140
typeof coordinates !== 'undefined' && coordinates.length > 0 && coordinates.length < 3,
141-
'The property `%s` is a `PIXI.Point` or `PIXI.ObservablePoint` and must be set to a comma-separated string of '
142-
+ 'either 1 or 2 coordinates, a 1 or 2 element array containing coordinates, or a PIXI Point/ObservablePoint. '
143-
+ 'If only one coordinate is given then X and Y will be set to the provided value. Received: `%s` of type `%s`.',
141+
'The property `%s` is a `Point` and must be set to a comma-separated string of '
142+
+ 'either coordinates, an array containing coordinates, or a Point.',
144143
prop,
145144
JSON.stringify(value),
146145
typeof value

packages/react/test/hooks.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('hooks', () =>
3333
});
3434

3535
expect(createApp).toThrow(
36-
'No Context found with `PIXI.Application`. Make sure to wrap component with `AppProvider`'
36+
'No Context found with `Application`. Make sure to wrap component with `AppProvider`'
3737
);
3838
});
3939

@@ -91,7 +91,7 @@ describe('hooks', () =>
9191
});
9292

9393
expect(createApp).toThrow(
94-
'No Context found with `PIXI.Application`. Make sure to wrap component with `AppProvider`'
94+
'No Context found with `Application`. Make sure to wrap component with `AppProvider`'
9595
);
9696
});
9797

packages/react/test/render.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('render', () =>
4545
test('invariant container', () =>
4646
{
4747
expect(() => render('something', null)).toThrow(
48-
'Invalid argument `container`, expected instance of `PIXI.Container`'
48+
'Invalid argument `container`, expected instance of `Container`'
4949
);
5050
});
5151

0 commit comments

Comments
 (0)