I have a Material UI submenu being populated from a json. The Main menu item holding this submenu array will be changed according to what is being selected. See image below
The Main menu item holding the submenus looks like this
<MenuItem
primaryText={this.state.selectedLanguage.name}
rightIcon={<ArrowDropRight />}
style={{userMenuItem}}
leftIcon={
<img className="flag" src={this.state.selectedLanguage.icon}/>
}
menuItems={languageMenu} //see below
/>
The nested menus are coming from here
const languageMenu =
<div>
{languages.map((item, index) => (
<MenuItem
key={index}
onClick={this.onLanguageChange}
primaryText={languages[index].name}
style={{userMenuItem}}
leftIcon={
<img className="flag" src={languages[index].icon}/>
}/>
))}
</div>
And ultimately, the data is stored in a json like this
const languages = [
{
name: 'English',
icon: './assets/images/flags/uk.png',
link: ''
},
{
name: 'Español',
icon: './assets/images/flags/Spain.png',
link: ''
},
{
name: 'Français',
icon: './assets/images/flags/France.png',
link: ''
}
...
];
In my poor understanding of React, I created an initial value for the slected language in the constructor state
constructor(props) {
super(props);
this.state = {
selectedLanguage:{
name:"English",
icon:"./assets/images/flags/uk.png",
},
}
}
and a function that will handle the changing (this is my problem area, I'm sure)
onLanguageChange = () => this.setState(
{
selectedLanguage: this.state.selectedLanguage.name,
}
);
I need to build this onChange() function correctly to alter the state based on the submenu clicked. This will give me the groundwork to build other properties that will trigger a translate feature on click as well
Any help will be appreciated. Thanks

<img className="flag" src={this.state.selectedLanguage.icon}/>when state change, notify and it change. Read facebook.github.io/react-native/docs/state.html