API

useHistory

Subscribe to the stack history store.

useHistory() subscribes to the stack history store.

TSX

1import { useHistory } from "react-native-screen-transitions";
2
3const history = useHistory();
4const latest = history.getMostRecent();
5const recent = history.getRecent(3);

It returns:

FieldMeaning
historyRead-only map of screen keys to history entries
getRecent(n)Most recent n entries, newest first
getByNavigator(key)Entries for one navigator, newest first
getPath(fromKey, toKey)Screen keys between two history entries
get(key)One history entry by screen key
getMostRecent()The latest history entry