Hi Campers,
It’s been a while, hope you’ve all been keeping well.
Would this be ok?
const DEFAULT_STATE = {
foo: foobar,
bar: barfoo
}
class Tuna extends Component {
constructor(props) {
super(props)
this.state = DEFAULT_STATE
}
...
reset = () => {
this.setState(DEFAULT_STATE)
}
...
}
or would this be any better (assuming there are no nested objects in DEFAULT_STATE)
const DEFAULT_STATE = {
foo: foobar,
bar: barfoo
}
class Tuna extends Component {
constructor(props) {
super(props)
this.state = {...DEFAULT_STATE}
}
...
reset = () => {
this.setState({...DEFAULT_STATE})
}
...
}
or just plain old this
class Tuna extends Component {
constructor(props) {
super(props)
this.state = {
foo: foobar,
bar: barfoo
}
}
...
reset = () => {
this.setState({
foo: foobar,
bar: barfoo
})
}
...
}
thank you.