Answer the question
In order to leave comments, you need to log in
Error during assignment by destructuring?
class Header{
constructor(props) {
let {props: {eventId, renderProps: {circleColor, crossColor}}} = props; // error
this.circleColor = circleColor
this.crossColor = crossColor
this.el = eventId
this.Render()
}
}
Answer the question
In order to leave comments, you need to log in
When destructuring, all the properties that you destructure must be set, which is why the error
let props = {eventId: 10, renderProps: {circleColor: "red", crossColor: "green"}};
let {eventId, renderProps: {circleColor, crossColor}} = props; // OK
let props = {renderProps: {circleColor: "red", crossColor: "green"}};
let {eventId, renderProps: {circleColor, crossColor}} = props; // Ошибка! не задано свойство enventId
let {props: {eventId, renderProps: {circleColor, crossColor}}} = props; // error
let {eventId, renderProps: {circleColor, crossColor}} = props;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question