October 2019
Intermediate to advanced
426 pages
11h 49m
English
First, we are going to use the useNavigation Hook to implement programmatic navigation. We want to automatically redirect to the corresponding post page after creating a new post.
Let's implement programmatic navigation in the CreatePost component using Hooks:
import { useNavigation } from 'react-navi'
const navigation = useNavigation()
useEffect(() => { if (post && post.data) { dispatch({ type: 'CREATE_POST', ...post.data }) navigation.navigate(`/view/${post.data.id}`) ...Read now
Unlock full access