我开始使用react-native-navigation
库。将我的屏幕应用于Navigation
对象时,该屏幕不再是交互式的,就像单击按钮一样。
我已将代码缩减为最少的代码:
index.js
:
import { Navigation } from 'react-native-navigation'
import WelcomeScreen from './WelcomeScreen'
Navigation.registerComponent(`WelcomeScreen`, () => WelcomeScreen)
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
stack: {
id: 'AppStack',
children: [
{
component: {
name: 'WelcomeScreen'
}
}
]
}
}
});
});
WelcomeScreen.js:
import React, {Component} from 'react'
import {Button, View} from 'react-native'
type Props = {};
export default class WelcomeScreen extends Component<Props> {
handleClick = () => {
console.log('Button Clicked')
}
render() {
return (
<View>
<Button title="Click" onPress={this.handleClick} />
</View>
)
}
}
该按钮没有显示任何单击动画,当然也没有控制台上的登录出现。
我在做什么错了?