Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorthand setState #21

Open
oliverjam opened this issue Sep 28, 2018 · 6 comments
Open

Shorthand setState #21

oliverjam opened this issue Sep 28, 2018 · 6 comments
Labels
good first issue Good for newcomers

Comments

@oliverjam
Copy link

It might be a bit easier to use the shorthand for setState when you don't need to access prevState.

e.g.

this.setState(prevState => {
  return { firstZombieAppeared: true };
})

to

this.setState({ firstZombieAppeared: true })

See the docs for more info

You may optionally pass an object as the first argument to setState() instead of a function

@MissArray
Copy link
Collaborator

MissArray commented Sep 28, 2018 via email

@Brymon Brymon added the good first issue Good for newcomers label Sep 28, 2018
@oliverjam
Copy link
Author

Hmm looks like a test script is failing?

npm ERR! Failed at the [email protected] build script

What did you configure as your build script on Netlify?

@MissArray
Copy link
Collaborator

MissArray commented Sep 28, 2018 via email

@oliverjam
Copy link
Author

Ah spotted why the build is failing:

"start": "parcel public/index.html",
"build": "parcel build index.html"

The build script needs to point to public/index.html too

@oliverjam
Copy link
Author

The underscore is standard syntax, it's just a convention for naming a function parameter you aren't going to use (you have to put something there so you can get to the index that's the second parameter)

@MissArray
Copy link
Collaborator

MissArray commented Sep 28, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants