Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Expected behavior
  • Loading branch information
eps1lon authored and Sebastian Silbermann committed Jan 11, 2023
commit 67b5c96357c6f72cdcdcef96f974b176e9e59c35
42 changes: 42 additions & 0 deletions packages/react-reconciler/src/__tests__/ReactNewContext-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,48 @@ describe('ReactNewContext', () => {
}
});

it('warns not if multiple renderers finished rendering the same context', () => {
spyOnDev(console, 'error');
const Context = React.createContext(0);

function Foo(props) {
Scheduler.unstable_yieldValue('Foo');
return null;
}

function App(props) {
return (
<Context.Provider value={props.value}>
<Foo />
<Foo />
</Context.Provider>
);
}

if (gate(flags => flags.enableSyncDefaultUpdates)) {
React.startTransition(() => {
ReactNoop.render(<App value={1} />);
});
} else {
ReactNoop.render(<App value={1} />);
}
expect(Scheduler).toFlushAndYield(['Foo', 'Foo']);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test above ("warns if multiple renderers concurrently render the same context") did not commit here. Without committing I would expect the warning. But here we actually commit so I don't think we should warn.


// Get a new copy of ReactNoop
jest.resetModules();
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');

// Render the provider again using a different renderer
ReactNoop.render(<App value={1} />);
expect(Scheduler).toFlushAndYield(['Foo', 'Foo']);

if (__DEV__) {
expect(console.error).not.toHaveBeenCalled();
}
});

it('provider bails out if children and value are unchanged (like sCU)', () => {
const Context = React.createContext(0);

Expand Down