相关疑难解决方法(0)

如何在多个组件中共享redux store

嗨,我有一个组件,我在我的反应应用程序中集成了redux.我打开第二个然后是第三个组件.我不希望将我在第一个组件中获得的数据传递给道具中的第二个然后第三个.

我想使用redux store来做到这一点.有没有办法做到这一点?

App.js

import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import RoundedButton from "./RoundedButton";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as actions from "./actions/index";

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      score: 0,
      status: "",
      userSelected: "",
      computerSelected: "",
      visibility: [true, true, true],
      buttonVisibility: false
    };
    this.clickitem = this.clickitem.bind(this);
    this.handlePlayAgain = this.handlePlayAgain.bind(this);
  }

  handlePlayAgain() {
    this.setState({
      buttonVisibility: false,
      visibility: [true, true, …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native redux react-redux

4
推荐指数
1
解决办法
5482
查看次数

标签 统计

javascript ×1

react-native ×1

react-redux ×1

reactjs ×1

redux ×1