Skip to content

how to use code splitting the right way #84

Answered by zamotany
chj-damon asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest way is to do it in code. I'm not sure what do you mean generate chunks based on route exactly but if you're using react-navigation you should be able to do something like this:

// MyScreen.js
function MyScreen() {
  // ...
}

// somewhere
const MyScreen = React.lazy(() => import('./MyScreen.js'));

<Stack.Navigator>
  <Stack.Screen name="MY_SCREEN" component={MyScreen} />
</Stack.Navigator>

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@chj-damon
Comment options

@zamotany
Comment options

Answer selected by jbroma
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants