从另一个组件得到状态反应

时间:2017-12-12 07:03:27

标签: reactjs

我如何从组件主页获取状态idf?我想从home.js到detail.js获得州idf。

my Home.js

class Home extends React.Component {

  constructor(){

    super();
    this.state = {
      dataOperations: [],
      distributorOperations: [],
      isLoading: true
    };
  }

  idFor(e) {
    this.state = {
      idf: e
    };
   window.location = "#/detail";
  }

我想在这里获取状态idf detail.js。这不是他的孩子

import React, {Component} from 'react';
import SingleProduct from '../assets/Singleproduct'
import ListProductHorizontal from '../assets/ListProducthorizontal'
import LoaderPage from '../assets/LoaderComponent'
import Home from './Home'
import Axios from 'axios'

class DetailProduct extends React.Component{

    constructor(){
        super();
        this.state = {
          dataOperations: [],
        isLoading: true
        };
      console.log(this.state.idf)

0 个答案:

没有答案