为什么使用react-native-navigation时屏幕不是交互式的?

时间:2019-06-08 18:04:21

标签: javascript reactjs react-native react-native-navigation

我开始使用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>
        )
    }
}

该按钮没有显示任何单击动画,当然也没有控制台上的登录出现。

我在做什么错了?

0 个答案:

没有答案