How to use register with connect function
cw-sanjeev opened this issue · comments
Hi,
I am trying to use this library, however i am stuck on how to use register function with connect.
export default connect(mapStateToProps)(RandomDetail); export default register({ require: () => require('./RandomDetail'), static: { navigationOptions: ({ navigation }) => { // all code from your component return { header: null, initialRouteName: Detail, } } } });
How do i club into single export
Hey @cw-sanjeev
The main idea behind this library is that you should put your register
function into separate file.
Let's imagine you have one file called View
, and inside of this file you have:
// your content of file
export default connect(mapStateToProps)(RandomDetail);
Then you can create a new file and call it index
and put your code:
export default register({
require: () => require('./RandomDetail'),
static: {
navigationOptions: ({ navigation }) => { // all code from your component
return { header: null, initialRouteName: Detail }
}
}
});
And that's all. If you need to refer to original file you can refer to View
file. If you need to use functionality of this library - refer to index
file.
Did I answer on your question?
yes this helps a lot, thanks!