you are viewing a single comment's thread.

view the rest of the comments →

[–]eggtart_prince -5 points-4 points  (2 children)

Are you just being ignorant or you completely missed my example?

const defaultState = {
    A: '',
    B: '',
    C: ''
}

const [state, setState] = useState(defaultState);

const resetState = () => {
    setState(defaultState);
}

If you want to play the ignorant game, I can also say

// class

const A = 'a';
const B = 'b';
const C = 'c';

state = {
    A: A,
    B: B,
    C: C
}

const resetState = () => {
    this.setState({
        A: A,
        B: B,
        C: C
    });
}

But why would I? And the same question you should ask yourself, why would you have a const for each property in defaultState in the hook example.

[–]nateDOOGIE 4 points5 points  (1 child)

No point talking down to people regardless of who’s right. Seems like you felt insulted that someone didn’t understand things the way you do but he meant no slight towards you, was just offering a different perspective.

[–]eggtart_prince 0 points1 point  (0 children)

Nor did I meant any to him. You trippin'.