Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ describe('createSubscription', () => {
},
() => null,
);
}).toWarnDev('Subscription must specify a getCurrentValue function');
}).toWarnDev('Subscription must specify a getCurrentValue function', {
withoutStack: true,
});
});

it('should warn for invalid missing subscribe', () => {
Expand All @@ -461,7 +463,9 @@ describe('createSubscription', () => {
},
() => null,
);
}).toWarnDev('Subscription must specify a subscribe function');
}).toWarnDev('Subscription must specify a subscribe function', {
withoutStack: true,
});
});

it('should warn if subscribe does not return an unsubscribe method', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,22 @@ describe('ReactComponentLifeCycle', () => {
const container = document.createElement('div');
expect(() =>
ReactDOM.render(<MyComponent x={1} />, container),
).toLowPriorityWarnDev([
'componentWillMount is deprecated and will be removed in the next major version. ' +
'Use componentDidMount instead. As a temporary workaround, ' +
'you can rename to UNSAFE_componentWillMount.' +
'\n\nPlease update the following components: MyComponent',
'componentWillReceiveProps is deprecated and will be removed in the next major version. ' +
'Use static getDerivedStateFromProps instead.' +
'\n\nPlease update the following components: MyComponent',
'componentWillUpdate is deprecated and will be removed in the next major version. ' +
'Use componentDidUpdate instead. As a temporary workaround, ' +
'you can rename to UNSAFE_componentWillUpdate.' +
'\n\nPlease update the following components: MyComponent',
]);
).toLowPriorityWarnDev(
[
'componentWillMount is deprecated and will be removed in the next major version. ' +
'Use componentDidMount instead. As a temporary workaround, ' +
'you can rename to UNSAFE_componentWillMount.' +
'\n\nPlease update the following components: MyComponent',
'componentWillReceiveProps is deprecated and will be removed in the next major version. ' +
'Use static getDerivedStateFromProps instead.' +
'\n\nPlease update the following components: MyComponent',
'componentWillUpdate is deprecated and will be removed in the next major version. ' +
'Use componentDidUpdate instead. As a temporary workaround, ' +
'you can rename to UNSAFE_componentWillUpdate.' +
'\n\nPlease update the following components: MyComponent',
],
{withoutStack: true},
);

// Dedupe check (update and instantiate new
ReactDOM.render(<MyComponent x={2} />, container);
Expand Down
29 changes: 26 additions & 3 deletions packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ describe('ReactComponentLifeCycle', () => {
'This is a no-op, but it might indicate a bug in your application. ' +
'Instead, assign to `this.state` directly or define a `state = {};` ' +
'class property with the desired state in the StatefulComponent component.',
{withoutStack: true},
);

// Check deduplication; (no extra warnings should be logged).
Expand Down Expand Up @@ -248,7 +249,9 @@ describe('ReactComponentLifeCycle', () => {
expect(() => {
const instance = ReactTestUtils.renderIntoDocument(element);
expect(instance._isMounted()).toBeTruthy();
}).toWarnDev('Component is accessing isMounted inside its render()');
}).toWarnDev('Component is accessing isMounted inside its render()', {
withoutStack: true,
});
});

it('should correctly determine if a null component is mounted', () => {
Expand All @@ -275,7 +278,9 @@ describe('ReactComponentLifeCycle', () => {
expect(() => {
const instance = ReactTestUtils.renderIntoDocument(element);
expect(instance._isMounted()).toBeTruthy();
}).toWarnDev('Component is accessing isMounted inside its render()');
}).toWarnDev('Component is accessing isMounted inside its render()', {
withoutStack: true,
});
});

it('isMounted should return false when unmounted', () => {
Expand Down Expand Up @@ -313,7 +318,9 @@ describe('ReactComponentLifeCycle', () => {

expect(() => {
ReactTestUtils.renderIntoDocument(<Component />);
}).toWarnDev('Component is accessing findDOMNode inside its render()');
}).toWarnDev('Component is accessing findDOMNode inside its render()', {
withoutStack: true,
});
});

it('should carry through each of the phases of setup', () => {
Expand Down Expand Up @@ -379,6 +386,7 @@ describe('ReactComponentLifeCycle', () => {
instance = ReactDOM.render(<LifeCycleComponent />, container);
}).toWarnDev(
'LifeCycleComponent is accessing isMounted inside its render() function',
{withoutStack: true},
);

// getInitialState
Expand Down Expand Up @@ -674,6 +682,7 @@ describe('ReactComponentLifeCycle', () => {
const container = document.createElement('div');
expect(() => ReactDOM.render(<Component />, container)).toWarnDev(
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
{withoutStack: true},
);
});

Expand Down Expand Up @@ -701,6 +710,7 @@ describe('ReactComponentLifeCycle', () => {
const container = document.createElement('div');
expect(() => ReactDOM.render(<Component value={1} />, container)).toWarnDev(
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
{withoutStack: true},
);
ReactDOM.render(<Component value={2} />, container);
});
Expand Down Expand Up @@ -728,6 +738,7 @@ describe('ReactComponentLifeCycle', () => {
const container = document.createElement('div');
expect(() => ReactDOM.render(<Component value={1} />, container)).toWarnDev(
'Unsafe legacy lifecycles will not be called for components using new component APIs.',
{withoutStack: true},
);
ReactDOM.render(<Component value={2} />, container);
});
Expand Down Expand Up @@ -756,6 +767,7 @@ describe('ReactComponentLifeCycle', () => {
' componentWillUpdate\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillMount extends React.Component {
Expand All @@ -775,6 +787,7 @@ describe('ReactComponentLifeCycle', () => {
' UNSAFE_componentWillMount\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillMountAndUpdate extends React.Component {
Expand All @@ -796,6 +809,7 @@ describe('ReactComponentLifeCycle', () => {
' UNSAFE_componentWillUpdate\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillReceiveProps extends React.Component {
Expand All @@ -815,6 +829,7 @@ describe('ReactComponentLifeCycle', () => {
' componentWillReceiveProps\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);
});

Expand All @@ -841,6 +856,7 @@ describe('ReactComponentLifeCycle', () => {
' componentWillUpdate\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillMount extends React.Component {
Expand All @@ -859,6 +875,7 @@ describe('ReactComponentLifeCycle', () => {
' UNSAFE_componentWillMount\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillMountAndUpdate extends React.Component {
Expand All @@ -879,6 +896,7 @@ describe('ReactComponentLifeCycle', () => {
' UNSAFE_componentWillUpdate\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);

class WillReceiveProps extends React.Component {
Expand All @@ -897,6 +915,7 @@ describe('ReactComponentLifeCycle', () => {
' componentWillReceiveProps\n\n' +
'The above lifecycles should be removed. Learn more about this warning here:\n' +
'https://fb.me/react-async-component-lifecycle-hooks',
{withoutStack: true},
);
});

Expand Down Expand Up @@ -964,6 +983,7 @@ describe('ReactComponentLifeCycle', () => {
expect(() => ReactDOM.render(<MyComponent />, div)).toWarnDev(
'MyComponent.getDerivedStateFromProps(): A valid state object (or null) must ' +
'be returned. You have returned undefined.',
{withoutStack: true},
);

// De-duped
Expand All @@ -984,6 +1004,7 @@ describe('ReactComponentLifeCycle', () => {
expect(() => ReactDOM.render(<MyComponent />, div)).toWarnDev(
'MyComponent: Did not properly initialize state during construction. ' +
'Expected state to be an object, but it was undefined.',
{withoutStack: true},
);

// De-duped
Expand Down Expand Up @@ -1209,6 +1230,7 @@ describe('ReactComponentLifeCycle', () => {
expect(() => ReactDOM.render(<MyComponent value="bar" />, div)).toWarnDev(
'MyComponent.getSnapshotBeforeUpdate(): A snapshot value (or null) must ' +
'be returned. You have returned undefined.',
{withoutStack: true},
);

// De-duped
Expand All @@ -1229,6 +1251,7 @@ describe('ReactComponentLifeCycle', () => {
expect(() => ReactDOM.render(<MyComponent />, div)).toWarnDev(
'MyComponent: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). ' +
'This component defines getSnapshotBeforeUpdate() only.',
{withoutStack: true},
);

// De-duped
Expand Down
11 changes: 11 additions & 0 deletions packages/react-dom/src/__tests__/ReactCompositeComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('ReactCompositeComponent', () => {
'render(): Calling ReactDOM.render() to hydrate server-rendered markup ' +
'will stop working in React v17. Replace the ReactDOM.render() call ' +
'with ReactDOM.hydrate() if you want React to attach to the server HTML.',
{withoutStack: true},
);

// New explicit API
Expand Down Expand Up @@ -279,6 +280,7 @@ describe('ReactCompositeComponent', () => {
'This is a no-op, but it might indicate a bug in your application. ' +
'Instead, assign to `this.state` directly or define a `state = {};` ' +
'class property with the desired state in the MyComponent component.',
{withoutStack: true},
);

// No additional warning should be recorded
Expand All @@ -303,6 +305,7 @@ describe('ReactCompositeComponent', () => {
'This is a no-op, but it might indicate a bug in your application. ' +
'Instead, assign to `this.state` directly or define a `state = {};` ' +
'class property with the desired state in the MyComponent component.',
{withoutStack: true},
);

// No additional warning should be recorded
Expand Down Expand Up @@ -466,6 +469,7 @@ describe('ReactCompositeComponent', () => {
"`render` or another component's constructor). Render methods should " +
'be a pure function of props and state; constructor side-effects are ' +
'an anti-pattern, but can be moved to `componentWillMount`.',
{withoutStack: true},
);

// The setState call is queued and then executed as a second pass. This
Expand Down Expand Up @@ -513,6 +517,7 @@ describe('ReactCompositeComponent', () => {
instance = ReactDOM.render(<Component />, container);
}).toWarnDev(
'Warning: setState(...): Cannot call setState() inside getChildContext()',
{withoutStack: true},
);

expect(renderPasses).toBe(2);
Expand Down Expand Up @@ -589,6 +594,7 @@ describe('ReactCompositeComponent', () => {
expect(() => instance.setState({bogus: true})).toWarnDev(
'Warning: Component.shouldComponentUpdate(): Returned undefined instead of a ' +
'boolean value. Make sure to return true or false.',
{withoutStack: true},
);
});

Expand All @@ -605,6 +611,7 @@ describe('ReactCompositeComponent', () => {
'Warning: Component has a method called ' +
'componentDidUnmount(). But there is no such lifecycle method. ' +
'Did you mean componentWillUnmount()?',
{withoutStack: true},
);
});

Expand All @@ -623,6 +630,7 @@ describe('ReactCompositeComponent', () => {
'If you meant to update the state in response to changing props, ' +
'use componentWillReceiveProps(). If you meant to fetch data or ' +
'run side-effects or mutations after React has updated the UI, use componentDidUpdate().',
{withoutStack: true},
);
});

Expand All @@ -641,6 +649,7 @@ describe('ReactCompositeComponent', () => {
expect(() => ReactTestUtils.renderIntoDocument(<Component />)).toWarnDev(
'Warning: Setting defaultProps as an instance property on Component is not supported ' +
'and will be ignored. Instead, define defaultProps as a static property on Component.',
{withoutStack: true},
);
});

Expand Down Expand Up @@ -1131,6 +1140,7 @@ describe('ReactCompositeComponent', () => {
'triggering nested component updates from render is not allowed. If ' +
'necessary, trigger nested updates in componentDidUpdate.\n\nCheck the ' +
'render method of Outer.',
{withoutStack: true},
);
});

Expand Down Expand Up @@ -1422,6 +1432,7 @@ describe('ReactCompositeComponent', () => {
expect(() => ReactDOM.render(<Foo idx="qwe" />, container)).toWarnDev(
'Foo(...): When calling super() in `Foo`, make sure to pass ' +
"up the same props that your component's constructor was passed.",
{withoutStack: true},
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ describe('ReactCompositeComponent-state', () => {
'Warning: Test.componentWillReceiveProps(): Assigning directly to ' +
"this.state is deprecated (except inside a component's constructor). " +
'Use setState instead.',
{withoutStack: true},
);

expect(ops).toEqual([
Expand Down Expand Up @@ -451,6 +452,7 @@ describe('ReactCompositeComponent-state', () => {
'Warning: Test.componentWillMount(): Assigning directly to ' +
"this.state is deprecated (except inside a component's constructor). " +
'Use setState instead.',
{withoutStack: true},
);

expect(ops).toEqual([
Expand Down
1 change: 1 addition & 0 deletions packages/react-dom/src/__tests__/ReactDOM-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ describe('ReactDOM', () => {
jest.resetModules();
expect(() => require('react-dom')).toWarnDev(
"This browser doesn't support requestAnimationFrame.",
{withoutStack: true},
);
} finally {
global.requestAnimationFrame = previousRAF;
Expand Down
Loading