refactor: move navigation.state to a route prop (#6)

This commit is contained in:
Michał Osadnik
2019-07-18 14:11:04 +01:00
committed by satyajit.happy
parent b775dbaacf
commit d3099c18b8
13 changed files with 84 additions and 108 deletions

View File

@@ -262,11 +262,11 @@ const StackRouter: Router<CommonAction | Action> = {
};
export function StackNavigator(props: Props) {
const { navigation, descriptors } = useNavigationBuilder(StackRouter, props);
const { state, descriptors } = useNavigationBuilder(StackRouter, props);
return (
<div style={{ position: 'relative' }}>
{navigation.state.routes.map((route, i) => (
{state.routes.map((route, i) => (
<div
key={route.key}
style={{
@@ -297,10 +297,7 @@ export function StackNavigator(props: Props) {
boxShadow: '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)',
}}
>
{
descriptors[navigation.state.routes[navigation.state.index].key]
.options.title
}
{descriptors[state.routes[state.index].key].options.title}
</div>
</div>
);