This repository was archived by the owner on Oct 27, 2021. It is now read-only.
This repository was archived by the owner on Oct 27, 2021. It is now read-only.
Allow to force left navbar button rendering #38
Open
Description
Context
Is there any way to force left button to appear? My use case is something like the following
I have a set of Routes
// App.js
<NativeRouter>
<Switch>
<Route path="/app/wizard component={Wizard} />
<Route exact path="/app" component={MainNavigation} />
</Switch>
</NativeRouter>
And then inside my Wizard component file
// Wizard.js
import { HeaderBackButton } from 'react-navigation';
class Wizard extends React.Component<Props, State> {
renderLeftButton = () => <HeaderBackButton onPress={this.props.history.goBack} />;
render() {
const { history } = this.props;
return (
<Navigation renderLeftButton={this.renderLeftButton}>
<Card exact path="/app/wizard" component={Step1} />
<Card path="/app/wizard/step-2" component={Step2} />
</Navigation>
);
}
}
Notice that in my Wizard component, I have to pass a custom renderLeftButton function, and this is ok, but I was wondering if it's possible to force the rendering of the back button whitout doing something like this? I checked the code and I found this line, but the scene.index === 0
does not work for all use cases I think?
- Also, whats the default onPress behaviour of the backButton? I'm guessing it is something like
history.goBack