Answer the question
In order to leave comments, you need to log in
How can I put this code into a separate Header.js file?
There is such an example.
https://snack.expo.io/@satya164/github.com-callsta...
And the file ./src/AppbarExample.js
This file changes the title before rendering.
That is, the title is custom.
static title = 'Appbar';
static navigationOptions = ({ navigation }) => {
const params = { ...initialParams, ...navigation.state.params };
return {
header: (
<Appbar.Header>
{params.showLeftIcon && (
<Appbar.BackAction onPress={() => navigation.goBack()} />
)}
<Appbar.Content
title="Title"
subtitle={params.showSubtitle ? 'Subtitle' : null}
/>
{params.showSearchIcon && (
<Appbar.Action icon="search" onPress={() => {}} />
)}
{params.showMoreIcon && (
<Appbar.Action icon={MORE_ICON} onPress={() => {}} />
)}
</Appbar.Header>
),
};
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question