Run code on app load
- 10 Apr 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
Run code on app load
- Updated on 10 Apr 2024
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
If you want to run specific code when your app loads (for example, initialize a chat service), you can include a hook
property on your module export object.
This method is an alternative to the componentDidMount
React API.
As an example, in our our react-native-example
module you can add the following.
export default {
title: "share",
navigator: ShareMessage,
hook: console.log("share module loaded")
}
When you run the app (using: npx react-native start
), you will see the console log the following message when the app loads: share module loaded
Was this article helpful?