Skip to content

Navigation Demo Error:this.props.navigator undefined #15078

Closed
@wangweiwei

Description

@wangweiwei

import React from 'react';
import PropTypes from 'prop-types';
import { AppRegistry, Button, NavigatorIOS, Text, View } from 'react-native';

export default class NavigatorIOSApp extends React.Component {
render() {
return (
<NavigatorIOS
initialRoute={{
component: MyScene,
title: 'My Initial Scene',
}}
style={{flex: 1}}
/>
)
}
}

class MyScene extends React.Component {
static propTypes = {
title: PropTypes.string.isRequired,
navigator: PropTypes.object.isRequired,
}

constructor(props, context) {
super(props, context);
this._onForward = this._onForward.bind(this);
}

_onForward() {
this.props.navigator.push({
title: 'Scene ' + nextIndex,
});
}

render() {
return (

Current Scene: { this.props.title }


)
}
}
AppRegistry.registerComponent('Demo', () => MyScene);
[
react-native-cli: 2.0.1
react-native: 0.46.4
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions