The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

hettlage (136) [Avatar] Offline
#1
While in this example it shouldn't make a difference, one might consider passing a function to setState in the toggleForm method in listing 2.12, in order to avoid issues caused by the asynchronous nature of setState (cf. https://medium.com/@shopsifter/using-a-function-in-setstate-instead-of-an-object-1f5cfd6e55d1).

toggleForm = (e) => {
    this.setState((prevState) => (
            {
                showNewCardForm: !prevState.showNewCardForm
            }
    ));
};

Marc Garreau (28) [Avatar] Offline
#2
Thanks for highlighting this. It seems this has become a best practice - we'll revisit related code for the next round of updates.