react-native - TypeError : (0 , _react.useMemo) 不是函数

标签 react-native

我尝试使用 redux,但出现了这个错误。

我是这样使用的:

import React, { Component } from 'react';
import { connect } from 'react-redux';


class LibraryList extends Component {
    render() {
        return null;
    }
}

const mapStateToProps = state => {
        console.log(state);
};

export default connect(mapStateToProps)(LibraryList);

但这给我一个错误。我应该怎么办。有人可以帮忙吗?

enter image description here

这是我的 app.js

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, FlatList } from 'react-native';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './src/reducers';
import LibraryList from './src/components/LibraryList';

const App = () => {

    return (
        <Provider store={createStore(reducers)} >
          <View>
         <LibraryList /> 
          </View>
        </Provider>
    );
}

最佳答案

useMemo 是一个新的 React Hook,仅在最新版本的 React 中可用。这个错误是说它对你不可用,所以要解决这个问题,你需要更新 react (如果你正在使用它,还需要更新 react native )。

如果你更新到,错误应该会消失 react16.8.6react-native0.59.5

参见 https://github.com/facebook/react-native/issues/24543了解更多信息

关于react-native - TypeError : (0 , _react.useMemo) 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55825988/

相关文章:

java - React Native,调试 native 库?

react-native - 在 React Native WebView 中启用弹出窗口

reactjs - 是否可以在所有 eslint 规则上显示警告而不是错误?

react-native - 如何从 React Native 传感器中的加速度计值中减去重力

android - 无法从 Windows 上的 Assets index.android.bundle 加载脚本

javascript - "autoCapitalize"不是有效的样式属性 - React Native 中的错误

javascript - React Native 组件未在 map() 迭代器内渲染

android - React Native 在应用内发送短信

reactjs - 如何修复 '_react["default"].memo 不是函数。(在 React Native 中的 '_react["default"].memo(connectFunction)' 错误?

javascript - 使用 react-native-maps 更改 MapView.Marker 的 pinColor