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
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,8 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
}
let sibling = nextFiber.sibling;
if (sibling !== null) {
// Set the return pointer of the sibling to the work-in-progress fiber.
sibling.return = nextFiber.return;
nextFiber = sibling;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,82 @@ describe('ReactNewContext', () => {
ReactNoop.flush();
});

// This is a regression case for https://github.com/facebook/react/issues/12686
it('does not skip some siblings', () => {
const Context = React.createContext(0);

class App extends React.Component {
state = {
step: 0,
};

render() {
ReactNoop.yield('App');
return (
<Context.Provider value={this.state.step}>
<StaticContent />
{this.state.step > 0 && <Indirection />}
</Context.Provider>
);
}
}

class StaticContent extends React.PureComponent {
render() {
return (
<React.Fragment>
<React.Fragment>
<span prop="static 1" />
<span prop="static 2" />
</React.Fragment>
</React.Fragment>
);
}
}

class Indirection extends React.PureComponent {
render() {
return <Consumer />;
}
}

function Consumer() {
return (
<Context.Consumer>
{value => {
ReactNoop.yield('Consumer');
return <span prop={value} />;
}}
</Context.Consumer>
);
}

// Initial mount
let inst;
ReactNoop.render(<App ref={ref => (inst = ref)} />);
expect(ReactNoop.flush()).toEqual(['App']);
expect(ReactNoop.getChildren()).toEqual([
span('static 1'),
span('static 2'),
]);
// Update the first time
inst.setState({step: 1});
expect(ReactNoop.flush()).toEqual(['App', 'Consumer']);
expect(ReactNoop.getChildren()).toEqual([
span('static 1'),
span('static 2'),
span(1),
]);
// Update the second time
inst.setState({step: 2});
expect(ReactNoop.flush()).toEqual(['App', 'Consumer']);
expect(ReactNoop.getChildren()).toEqual([
span('static 1'),
span('static 2'),
span(2),
]);
});

describe('fuzz test', () => {
const Fragment = React.Fragment;
const contextKeys = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
Expand Down