react-native-router-flux
适用于我的应用程序中除TimeInput
以外的所有场景。我正在通过新闻处理程序触发操作。
您知道为什么它不起作用吗?预先感谢。
操作:
import { Actions } from 'react-native-router-flux';
class Dashboard extends Component {
constructor() {
super();
this.state = {
loading: true,
contact: {},
}
}
async componentDidMount() {
try {
const contact = await retrieveAddressBook();
this.setState({ loading: false, contact: contact })
} catch (error) {
Alert.alert(error.detail[0]);
}
}
handleOnClick = () => {
Actions.TimeInput();
}
render() {
if (this.state.loading) {
return (
<>
<Loader />
</>
)
} else {
return (
<View>
<Text>
{this.state.contact[0].name}
</Text>
<Text onPress={this.handleOnClick}>
{this.state.contact[0].phone}
</Text>
</View>
)
}
}
}
export default Dashboard;
路由器
import TimeInput from '../components/TimeInput'
class App extends Component {
render() {
return (
<StoreProvider store={store}>
<PaperProvider>
<Router>
<Scene key='root'>
<Scene
key='RootContainer'
component={RootContainer}
title='RootContainer'
hideNavBar={true}
initial
/>
<Scene
key='PhoneNumberInput'
component={PhoneNumberInput}
title='PhoneNumberInput'
hideNavBar={true}
/>
<Scene
key='SmsCodeInput'
component={SmsCodeInput}
title='SmsCodeInput'
hideNavBar={true}
/>
<Scene
key='Dashboard'
component={Dashboard}
title='Dashboard'
hideNavBar={true}
/>
<Scene
key='TimeInput'
component={TimeInput}
title='TimeInput'
hideNavBar={true}
/>
</Scene>
</Router>
</PaperProvider>
</StoreProvider>
);
}
}
export default (App);
TimeInput组件
import DateTimePicker from 'react-datetime-picker'
class TimeInput extends Component {
render() {
return (
<>
<DateTimePicker />
</>
)
}
}
export default TimeInput;