I'm a beginner with react native. But not with JavaScript.
In my app.js I would like to do something like that :
export default class App extends Component {
constructor(props){
super(props);
//init a lot of modules
this.all_modules = [];
var MenuGame = require ('/modules/mod_menu/mod_menu.js');
this.all_modules.push(new MenuGame());
}
render(){
//render all modules
var views = [];
views = this.all_modules.map(function(module){
return module.render();
});
return (<View>{views}</View>);
}
}
In my mod_menu.js I have :
Class MenuGame extends React.component{
render(){
return(<Text>foo</Text>);
}
}
When I run this code I get the following error Element type is invalid : expected a string or a class/function but got undefined check the render method of 'App'
The aim is to have a kind of controller App.js who is responsible for the life cycle of the app. App.js just need to init all modules and call render on them. Each module will build the App.
Can you help me ?
EDIT : source code : https://jsfiddle.net/n7habkt3/