I'm new to React and the concepts are still new to me. I'm working on this example and I would like to know if it would be possible to re-write it in another way and avoid using .bind altogether. The goal here is just to minimize the code written required as much as possible!
Full example can be found here:
https://codepen.io/akamali/pen/awvqeM
The component simply render a menu list and when you click on an item it highlight the selected text.
ES5
<ul className='languages'>
{languages.map(function (lang) {
return (
<li
style={lang === this.state.selectedLanguage ? {color: '#d0021b'} : null}
onClick={this.updateLanguage.bind(null, lang)}
key={lang}>
{lang}
</li>
)
}, this)}
</ul>
**ES6 => **
<ul className='languages'>
{languages.map(lang => {
return (
<li
style={lang === this.state.selectedLanguage ? {color: '#d0021b'} : null}
onClick={this.updateLanguage.bind(null, lang)}
key={lang}>
{lang}
</li>
)
},)}
</ul>