3 ms·
Wrapping them in methods is an easy way to fix that... but not sure if it is any cleaner. render() { return <If cond={ this.state.loggedIn }
by Keithamus 10y ago
Wrapping them in methods is an easy way to fix that... but not sure if it is any cleaner.
render() {
return <If
cond={ this.state.loggedIn }
then={() => `Hello ${ this.state.userName }`}
else={() => `Please log in` }
/>
}
- spion 10y agoOr with an algebraic Maybe data type {this.state.user.case({ some: user => `Hello ${ user.name }` none: () => `Please log in` })} Or for async requests that are in progress, an algebraic 3-state type: https://twitter.com/Tholle1234/status/804796967222202372 https://twitter.com/Tholle1234/status/804796967222202372