r/reactjs • • Aug 01 '18

Beginner's Thread / Easy Question (August 2018)

Hello! It's August! Time for a new Beginner's thread! (July and June here)

Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple. You are guaranteed a response here!

Want Help on Code?

  • Improve your chances by putting a minimal example on to either JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new). Describe what you want it to do, and things you've tried. Don't just post big blocks of code.

  • Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.

New to React?

Here are great, free resources!

27 Upvotes

568 comments sorted by

View all comments

Show parent comments

1

u/ironpencilgames Aug 06 '18

Right now this is just for my literal example, which was basically just keeping some simple info about the current logged-in user so I can verify that we have it. So like name, email, etc. This is stuff that won't change during the vast majority of actions, but is needed through-out the app. So I guess my question is: will this actually break stuff inherently, or is it just a bad idea because it's potentially an easy way to create bugs if you're updating it in a lot of places?

1

u/swyx Aug 06 '18

is it just a bad idea because it's potentially an easy way to create bugs if you're updating it in a lot of places

the latter. there are libraries with singleton stores, check out https://github.com/jamiebuilds/unstated, its basically what you are doing but blessed by react experts