tezvyn:

Escape Prop Drilling with React Navigation Hooks

Source: reactnavigation.orgintermediate

React Navigation hooks let components control navigation without prop drilling. `useNavigation` gives you the `navigation` object to change screens, while `useRoute` provides data about the current screen. The footgun: they only work inside a navigator.

React Navigation hooks like `useNavigation` and `useRoute` let components control navigation without prop drilling. `useNavigation` gives you the `navigation` object for actions like `navigate()` or `goBack()`, while `useRoute` provides the `route` object for reading params. This is ideal for deeply nested components that need to trigger a screen change. The main footgun: these hooks only work for components rendered inside a screen managed by a navigator; they will fail otherwise.

Read the original → reactnavigation.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Escape Prop Drilling with React Navigation Hooks · Tezvyn