This article (and other places) mention now calling functions inside of render:
https://levelup.gitconnected.com/optimize-react-performance-c1a491ed9c36?ref=reddit
I've always used a pattern for large React class components where I'll move some of the JSX out of the render function into methods. This avoids having a billion little one-time-use separate components and it also avoids having to put lengthy if/then or ternary logic inside of a render area which I find slightly harder to read.
class HelpModal extends React.Component {
state = { visible: false };
renderContent = () => {
if (this) {
return <div />
}
if (that) {
return <span />
}
}
render() {
return (
<Modal visible={this.state.visible}>
{this.renderContent()}
</Modal>
);
}
}
I've seen this strategy in a bunch of places, but now it sounds like, based on the above blog post, that this may be a bad practice performance-wise?