Skip to content

Instantly share code, notes, and snippets.

@JakeCoxon
Created February 17, 2019 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeCoxon/9fccdac4af49fd28ffc246487e714f5d to your computer and use it in GitHub Desktop.
Save JakeCoxon/9fccdac4af49fd28ffc246487e714f5d to your computer and use it in GitHub Desktop.
React navigation header hooks example
function MyScreen({}) {
const [numSelected setNumSelected] = useState(false);
useHeaderTitle(numSelected > 0 ? `${numSelected} tasks selected` : 'Task selection');
return ...
}
function MyScreen({}) {
const [doApiRequest, isLoading] = useMyApi();
useHeaderRight(
isLoading ? <ActivityIndicator /> :
<Button onPress={doApiRequest}>Done</Button>
)
return ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment