Run code on app load
  • 10 Apr 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Run code on app load

  • Dark
    Light
  • PDF

Article summary

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?

What's Next