相关疑难解决方法(0)

如何在打字稿中使用react-navigation的withNavigation?

我正在尝试使用react-native,react-navigation和Typescript一起创建一个应用程序。总共只有两个屏幕(HomeScreenConfigScreen)和一个组件(GoToConfigButton),如下所示。

主屏幕

import React from "react";
import { NavigationScreenProps } from "react-navigation";
import { Text, View } from "react-native";
import GoToConfigButton from "./GoToConfigButton";

export class HomeScreen extends React.Component<NavigationScreenProps> {
  render() {
    return (
      <View>
        <Text>Click the following button to go to the config tab.</Text>
        <GoToConfigButton/>
      </View>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

GoToConfigButton

import React from "react";
import { Button } from "react-native";
import { NavigationInjectedProps, withNavigation } from "react-navigation";

class GoToConfigButton extends React.Component<NavigationInjectedProps> {
  render() { …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs react-native react-navigation

6
推荐指数
1
解决办法
3649
查看次数