在连接上下文中找不到“商店”

Use*_*ser 6 javascript reactjs react-native redux

import React from 'react';
import { View, TouchableOpacity, StyleSheet, Button, Text, NativeModules, Image } from 'react-native';
import { connect } from 'react-redux'
import { Icon } from 'native-base';

const ShoppingCartIcon = (props) => (
    <View>
        <View style={{
            position: 'absolute', height: 30, width: 30,
            borderRadius: 15, backgroundColor: 'rgba(95,197,123,0.8)', right: 45,
            bottom: 15, alignItems: 'center', justifyContent: 'center', zIndex: 2000
        }}>
            <Text stye={{ color: 'white' }}> {props.cartItems.length} </Text>
        </View>
        <Icon name="cart" ></Icon>
        <Button style={styles.but}
            title="Add"
            onPress={() => {
                this.props.navigation.navigate('ShopScreen');
                this.props.navigation.closeDrawer();
            }}
        />
    </View>

)

const mapStateToProps = (state) => {
    return {
        cartItems: state
    }
}

export default connect(mapStateToProps)(ShoppingCartIcon);

const styles = StyleSheet.create({
    but: {
        justifyContent: 'center',
        alignItems: 'center',
        fontSize: 20,
        //justifyContent: 'flex-end',
        //textAlign: 'center',
        //flexDirection:'column',
    }
})
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用 redux,但收到此错误:无法在“Connect(ShoppingCartIcon)”的上下文中找到“store”。将根组件包装在 a 中,或者将自定义 React 上下文提供程序传递给连接选项中的 Connect(ShoppingCartIcon) 并将相应的 React 上下文使用者传递给 Connect(ShoppingCartIcon)。

看来问题在于我将抽屉容器屏幕包装在提供程序中,但我不知道如何修复它。

感谢您的帮助

import React, { Component } from 'react';
import { View, Text, Button, StyleSheet, Image, Platform, TextInput, ScrollView, Title } from 'react-native';
import DrawSt from './App.js'
import { Provider } from 'react-redux'
import store from './store'
//import { NavigationContainer } from '@react-navigation/native'

export default class Start extends React.Component {
    render() {
        return (
            <Provider store={store}>
                    <DrawSt />
            </Provider>

        )
    }
}
Run Code Online (Sandbox Code Playgroud)

import React, { Component } from 'react';
import { View, Text, Button, StyleSheet, Image, Platform, TextInput, ScrollView, Title } from 'react-native';
import DrawSt from './App.js'
import { Provider } from 'react-redux'
import store from './store'
//import { NavigationContainer } from '@react-navigation/native'

export default class Start extends React.Component {
    render() {
        return (
            <Provider store={store}>
                    <DrawSt />
            </Provider>

        )
    }
}
Run Code Online (Sandbox Code Playgroud)

在“Connect(ShoppingCartIcon)”上下文中找不到“商店”。将根组件包装在 a 中,或者将自定义 React 上下文提供程序传递给连接选项中的 Connect(ShoppingCartIcon) 并将相应的 React 上下文使用者传递给 Connect(ShoppingCartIcon)。

小智 1

<Provider store={store}> 你应该像那样提供 商店

 import { createStore } from "redux";
 import reducer from '.store/reducer'

 const store = createStore(reducer);
Run Code Online (Sandbox Code Playgroud)