将 Redux 存储数据作为 Props 从 parent1 -> parent2 -> child 传递(或)使用 mapToStateProps 直接在子组件中调用 redux 存储?

Passing Redux store data as Props from parent1 -> parent2 -> child (OR) call redux store directly in Child component with mapToStateProps?

将 Redux 存储数据从父组件(它已经用于某些其他功能)作为 props 传递给子组件是否比在子组件中直接调用 Redux 存储更好?

我试过传递道具以及直接在子组件中调用。在功能上找不到太大的区别,只是想知道什么是标准做法以及它如何影响大数据的性能。

ExampleReduxdata: {'Apple', 'Banana', 'Mango', 'Orange'}

    class ParentComponent1 extends React.Component {

    render(){
     return (<ParentComponent2 reducerData={this.props.reducerData} />
    }

    const mapStateToProps = {

    reducerData: state.ExampleReduxdata,
     }
    }
    class ParentComponent2 extends React.Component{
    render(){
     return (<ChildComponent reducerData={this.props.reducerData} />
     }

    }
    (OR)


    class ChildComponent extends React.Component{

    render(){
     return (
        <div>{this.props.reducerData}</div>
       );
    }

    const mapStateToProps = {

    reducerData: state.ExampleReduxdata,
    } 

    }

基于主要的 Redux 文档:

React bindings for Redux separate presentational components from container components. This approach can make your app easier to understand and allow you to more easily reuse components.

所以我想为了使您的组件可重用并遵循单一真实来源原则,最好用 connect 方法包装您的组件!

在功能组件中避免这些方法和包装的另一种简单方法是 redux hooks useSelectoruseDispatch.