Description
Do you want to request a feature or report a bug?
Report a possible bug
What is the current behavior?
When Component A renders Component B with a children prop that is a react component / JSX fragment any render of component A will recreate said children prop
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).
Example Code:
import React from 'react';
class ComponentWithChildren extends React.PureComponent {
render() {
console.log("RENDER COMP")
return <span>Hello{this.props.children}</span>
}
}
class Children extends React.PureComponent {
render() {
return (
<div>
these are children
<span>nested</span>
</div>
)
}
}
class App extends React.PureComponent {
update = () => this.setState({ count: this.state.count + 1 })
state = {
count: 0
}
render() {
console.log("RENDER APP")
return (
<div>
<button onClick={this.update}>Update</button>
<ComponentWithChildren>
<Children />
</ComponentWithChildren>
</div>
)
}
}
export default App;
What is the expected behavior?
I would expect ComponentWithChildren not to re-render because none of its props actually changed
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 15.4.1