Во-первых, вам нужно больше узнать о реакции и о том, как передавать значения в качестве реквизитов между вашими компонентами.
Во-вторых, в вашей функции рендеринга вы должны передавать значения в качестве реквизитов в компонент ProductList.
render() {
const {
categoryId,
categoryName
} = this.props;
return (
<MainComponent>
<label>Your categoryId is: </label>
{categoryId}
<label>Your categoryName is: </label>
{categoryName}
<label>The products of this category are: </label>
<div>
<ProductLists categoryId={categoryId} categoryName={categoryName} />
</div>
</MainComponent>
);
};
}
Наконец, для того, чтобы увидеть categoryId и categoryotyName в вашем ProductList, вам просто нужно отобразить их.
class ProductLists extends Component {
constructor(props) {
super(props);
this.state = {
expanded: false
};
}
render() {
return (
<div>
CategoryId: {this.props.categoryId}
CategoryName: {this.props.categoryName}
<TextBox/>
<DropDownList />
</div>
);
}
}
ProductLists.propTypes = {
categoryId: PropTypes.number,
categoryName: PropTypes.string
};
export default ProductLists;