Search code examples
react-nativereact-native-web

how to pass props to react-native when using React native web?


When I use react-native-web , my App entry looks like the following

 AppRegistry.registerComponent('SnsAdvertiser', () => Advertiser)                                                                                                                                                                            
 AppRegistry.runApplication('SnsAdvertiser', { rootTag: document.getElementById('mainApp') });

I wonder how I can pass props to the root Component in this case Advertiser in this case in a web environment.


Solution

  • runApplication accepts another parameter in the second argument called initialProps alongwith rootTag

     AppRegistry.runApplication('SnsAdvertiser', {
         rootTag: document.getElementById('mainApp'),
         initialProps: {...}
     });