反应原生redux连接未定义的功能

问题描述 投票:3回答:3

我有以下代码库

世博链接

https://snack.expo.io/@mparvez19861/redux-example

app.js

 <Provider store={store}>
                <View style={styles.container}>
                    <Navigator />
                </View>
            </Provider>

Navigator.js

const AuthStack = createStackNavigator({
  // { SignIn: SignInScreen }
  // SignIn: { screen: EmailPwdLogin }
    Login: { screen: LoginScreen },
    Signup: { screen: SignupScreen },
  });
const drNav = createDrawerNavigator(
  {

    Screen2: {
        screen: Screen2
      },
     SignOut: {
      screen: SignOutScreen
    }
  }
)

export default createAppContainer(createSwitchNavigator(
  {
    // screendesign: screendesign,
    SplashScreen: SplashScreen,
    App: drNav,
    AuthStack: AuthStack
  },
  {
    initialRouteName: 'SplashScreen',
  }
));

login.js

  import React, { Component } from 'react';
import { StyleSheet, View, Text, TextInput, Button, Alert } from 'react-native';
import { NavigationActions } from 'react-navigation';
import firebase from 'react-native-firebase';

import { connect } from 'react-redux';
import { getUserData, watchUserLogin } from '../redux/app-redux';



const mapStateToProps = (state) => {
    return {
        userData: state.userData,
    };
}

const mapDispatchToProps = (dispatch) => {
    return {
        getUserData: (user) => { dispatch(getUserData(user)) },
    };
}

class LoginScreen extends Component {

    constructor(props) {
        super(props);
        this.state = {
            userData: null,
            email: "",
            password: "",
        };
    }

    onLoginPress = () => {
        firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
            .then((user) => {
                //this.state.userData = user;
                this.setState({ userData: user })
                this.onGetUserData(user);
               // this.props.navigation.navigate("friendsOnWay");
            }, (error) => { Alert.alert(error.message); });
    }

    onGetUserData = (user) => {
        this.props.getUserData(user);
    }

    onCreateAccountPress = () => {
        // var navActions = NavigationActions.reset({
        //     index: 0,
        //     actions: [NavigationActions.navigate({routeName: "Signup"})]
        // });
        // this.props.navigation.dispatch(navActions);
        // this.props.navigation.navigate("Signup");
    }



    render() {
        return (
            <View style={{ paddingTop: 50, alignItems: "center" }}>

                <Text>Login</Text>

                <TextInput style={{ width: 200, height: 40, borderWidth: 1 }}
                    value={this.state.email}
                    onChangeText={(text) => { this.setState({ email: text }) }}
                    placeholder="Email"
                    keyboardType="email-address"
                    autoCapitalize="none"
                    autoCorrect={false}
                />

                <View style={{ paddingTop: 10 }} />

                <TextInput style={{ width: 200, height: 40, borderWidth: 1 }}
                    value={this.state.password}
                    onChangeText={(text) => { this.setState({ password: text }) }}
                    placeholder="Password"
                    secureTextEntry={true}
                    autoCapitalize="none"
                    autoCorrect={false}
                />

                <Button title="Login" onPress={this.onLoginPress} />
                <Button title="Create account..." onPress={this.onCreateAccountPress} />
            </View>
        );
    }
}

const styles = StyleSheet.create({

});

export default connect(mapStateToProps, mapDispatchToProps)(LoginScreen);

抛出错误

TypeError:TypeError:undefined不是函数(计算'(0,_react.useMemo)')

此错误位于以下位置:在SceneView中的SceneFine(由SceneView创建)(在StackViewLayout.js:784中)在RCTView(在View.js:45)中的视图(在StackViewLayout.js:783)中的RCTView(在View.js中) :45)在视图(在StackViewLayout.js:782)的RCTView(在View.js:45)中的视图(在createAnimatedComponent.js:153)中的AnimatedComponent(在StackViewCard.js:69)在RCTView中(在View.js上) :45)在View中(在createAnimated.js:153)的AnimatedComponent(at screens.native.js:59)中,在Screen(在StackViewCard.js:57)的Card中(在createPointerEventsContainer.js:27)在Container中(在StackViewLayout)在视图中的RCTView(在View.js:45)的ScreenContainer(在StackViewLayout.js:311)中的视图(在屏幕上,在屏幕上,在屏幕上,在View.js:83处)中的RCTView(在View.js:45处)(.js:860)在createAnimatedComponent.js:153)中的AnimatedComponent(在StackViewLayout.js:307)中的PanGestureHandler(在StackViewLayout.js:300)StackViewLayout(at withOrientation.js:30)in withOrientation(at StackView.js:79)in RCTView(在View.js:45)in View(在Tran sitioner.js:214)在TransitionView中的Stacker(在StackView.js:22中),在NavView中的Navigator中创建的(在createKeyboardAwareNavigator.js:12中),在SwitchView中的SceneView(由SwitchView创建)的KeyboardAwareNavigator(由SceneView创建)中。在导航器中创建的Navigator(在createAppContainer.js:388中)在NavigationContainer(在App.js:94)的RCTView(在View.js:45)中在View(在App.js:93)的Provider中(在App。在视图中的RCTView(在View.js:45)中的视图(在AppContainer.js:98中)的RCTView(在View.js:45)中的应用程序(在renderApplication.js:34)中的js:92)(在AppContainer中)。 js:115)在AppContainer中(在renderApplication.js:33)

此错误位于以下位置:位于应用程序中的提供程序(位于App.js:92)中的视图(位于App.js:93)中的RCTView(位于View.js:45)中的NavigationContainer(位于App.js:94) renderApplication.js:34)在RCTView(在View.js:45)的视图中(在AppContainer.js:98)在RCTView(在View.js:45)的视图中(在AppContainer.js:115)在AppContainer中(在renderApplication.js:33)ConnectFunction D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-redux \ lib \ components \ connectAdvanced.js:131:41 updateFunctionComponent D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:11441:29 updateSimpleMemoComponent D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js :11352:4 updateMemoComponent D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:11224:8 beginWork D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \反应母语\库\渲染\ oss \ ReactNativeRenderer-dev.js:12824:8 performUnitOfWork D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:16075:21 workLoop D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:16115:41 renderRoot D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:16219:15 performWorkOnRoot D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:17198:17 performWork D :\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:17099:24 performSyncWork D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:17060:14 requestWork D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.j s:16925:19 scheduleWork D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:16724:16 scheduleRootUpdate D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:17413:15 updateContainerAtExpirationTime D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer- dev.js:17447:28 updateContainer D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:17537:4 render D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ Renderer \ oss \ ReactNativeRenderer-dev.js:18191:20 renderApplication D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ ReactNative \ renderApplication。 js:59:34运行D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ ReactNative \ AppRegistry.js:101:10 runApplication D:\ Rnd \ React Nat ive \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ ReactNative \ AppRegistry.js:195:26 __callFunction D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js: 366:47 D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:106:26 __guard D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:314:10 callFunctionReturnFlushedQueue D:\ Rnd \ React Native \ Project \ WhoAroundMe \ node_modules \ react-native \ Libraries \ BatchedBridge \ MessageQueue.js:105:17

我做错了请帮忙

react-native redux react-redux react-native-android
3个回答
3
投票

版本7.0.1的redux-sagas“现在要求最小React版本为16.8.4或更高版本。”


2
投票

我有同样的问题,我使用react-native版本0.58.6和react-redux版本6.0.1,它运作良好。


2
投票

我得到了同样的错误。我更新了我的版本以进行反应并对原始版本以及redux和react-redux做出反应。它解决了。希望也适合你。

© www.soinside.com 2019 - 2024. All rights reserved.