У меня есть два компонента: Orders
и FormDialog
, первый является отцом второго.
Я пытаюсь отправить данные в виде свойств от Orders
до FormDialog
следующим образом:
Компоненты заказов
class Orders extends Component {
state={
open: false,
order: {
address: '',
client: '',
date: '',
estimated_time: '',
id: 0,
order_no: '',
original_order_no: '',
phone: '',
place: '',
position: '',
status: '',
team: ''
}
}
render() {
return (
<div>
<FormDialog open={this.state.open} order={this.state.order}/>
</div>
);
}
Компонент FormDialog
export default class FormDialog extends React.Component {
constructor(...props) {
super(...props);
this.state = {
order: {
address: '',
client: '',
date: '',
estimated_time: '',
id: 0,
order_no: '',
original_order_no: '',
phone: '',
place: '',
position: '',
status: '',
team: ''
}
};
}
async componentWillMount()
this.setState({order: this.props.order})
};
render() {
return (
<div>{this.state.order.team}</div>
)}
Это отображение TypeError: this.state.order is undefined
при попытке компиляции. Любое предложение?