我在reactjs应用程序中工作。我想将数据传递给它的子组件。我将Parent作为父组件,将Test1和Test2作为其子组件。我在父组件中也有不断的数据。我想在其所有子组件中传递相同的数据。如何在Test1组件中访问此数据 父母代码
import React, {PropTypes} from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {load} from 'redux/modules/viewlodging';
import Test1 from './Test1';
import Test2 from './Test2';
@connect(
state => ({data: state.viewlodging.data}),
dispatch => bindActionCreators({load}, dispatch))
export default class Viewlisting extends React.Component {
static propTypes = {
data: PropTypes.object,
load: PropTypes.func.isRequired
}
render() {
const {data} = this.props;
return (
<div>
<div className="row font14 relative">
<div className="container relative">
<div className="col-md-8">
<div className="row details">
<{data.title}>
</div>
</div>
<div className="col-md-4" >
<Test1/>
<Test2/>
</div>
</div>
</div>
</div>
);
}
}
在Test1中
import React from 'react';
export default class Test1 extends React.Component {
render() {
return (
<div className="summary-info">
<div>From Test1</div>
</div>
);
}
}
如何在Test中访问数据?