Reputation: 450
I am passing in part of my state into component props like this:
<EditBoard
boardArr={{
boardid: this.state.boardid,
boardvalue: this.state.boardvalue,
boardcolor: this.state.boardcolor,
}}
/>
This works but I understand this is not the best way to go. Wondering how I might destructure this in a more elegant way.
Upvotes: 1
Views: 48
Reputation: 167250
Destructuring this way works, and also you don't need to do key: key
. I'd say, do this way:
const { boardid, boardvalue, boardcolor } = this.state;
return (
<div>
<EditBoard
boardArr={{
boardid,
boardvalue,
boardcolor
}}
/>
</div>
);
Upvotes: 2