0

Consider <MenuComponent /> is the reusable component. Which code perform better in this scenario.

Option 1

render() {
   return this.state.shouldHidden ? null : <MenuComponent />
}

Option 2

render() {
   return <MenuComponent hidden={this.state.shouldHidden}/>
}
1

1 Answer 1

1

Obviously 1. because if hidden at least one function call can be avoided.

But, seriously, it will save you only some microseconds.
Never forget: premature optimization is the root of all evil :)

Sign up to request clarification or add additional context in comments.

1 Comment

If think of 'reflow'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.