在“ Connect(App)”的上下文中找不到“商店”。将根组件包装在<Provider>

时间:2019-07-18 20:57:59

标签: react-native react-redux

在“ Connect(App)”的上下文中找不到“商店”。要么将根组件包装在中,要么将自定义React上下文提供程序传递给和相应的React

*

我认为问题在于新的react context API ...

在同一位置检查“围高”帖子

https://dev.to/wgao19/upgrading-to-react-redux-v6-around-the-new-context-api-5725

*

import React, { Component } from 'react';
import { Text, View } from 'react-native';
import{connect, Provider} from 'react-redux';

import store  from './Redux/store.js';

const ContextA = React.createContext();
class App extends Component{
  render(){
    return (
      <Provider store = {store} context = {ContextA} > 
        <View >
          <Text> Contacts </Text>
        </View>
      </Provider>
    )
  }
}
const mapStP= state =>({contacts : state.contacts});
export default connect(mapStP, null , null, {context : ContextA})(App);

依赖项

"dependencies": {
    "expo": "^33.0.0",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
    "react-native-web": "^0.11.4",
    "react-redux": "^7.1.0",
    "redux": "^4.0.4"
  },

1 个答案:

答案 0 :(得分:0)

您已将提供者的上下文选择为“ ContextA”,而不是应用程序。因此,应用程序中没有上下文的定义。很难确切地知道您想要什么,但是您可以像这样解决这个问题。

App.js

from keras import models
model = load_model('cats_and_dogs_small_2.h5')

您的组件

Yourcomponent.js

import React, { Component } from 'react';
import { Text, View } from 'react-native';

class App extends Component{
  render(){
    return (
        <View >
          <Text> Contacts </Text>
        </View>
    )
  }
}
export default App