Who can explain this setState call in React

4 views
Skip to first unread message

rv

unread,
May 23, 2020, 5:14:22 AM5/23/20
to gdg-yaounde, gdg-douala, barcamp...@googlegroups.com
Greetings,

I came across this call and don't understand how it works, which concept is behind?

    const todos = [...this.state.todos, todo]
    this.setState({todos, inputValue:''}, () => { console.log(this.state)})


I was expecting

    this.setState({todos: todos, inputValue:''}, () => { console.log(this.state)})

Thank you.

rv

unread,
May 23, 2020, 10:17:57 AM5/23/20
to gdg-yaounde, gdg-douala, barcamp...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages