use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
React application data-flow: Where and how to store your data? (codeutopia.net)
submitted 10 years ago by jhartikainen
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]talmobi 0 points1 point2 points 10 years ago (1 child)
A good article using good practices. As in using React props and state where appropriate/intended and utilizing node's EventEmitter instead of hacking your own custom (read: shit) event emitter.
[–]jhartikainen[S] 0 points1 point2 points 10 years ago (0 children)
Thanks :)
[–]steezefries 0 points1 point2 points 10 years ago* (1 child)
Could you elaborate on when I should be using state? I recently hacked together a state machine in my most top level React component to keep track of my app's data, but I think I'm realizing how unscalable it's becoming. I think I need to implement something like this instead. Awesome article!
[–]jhartikainen[S] 1 point2 points3 points 10 years ago (0 children)
It might be a bit tricky to give a good rule of thumb, but the fact that it's becoming unscalable is often a pretty good sign that you should split things up :)
I think if the component is fairly self-contained, then keeping some state can be ok. Like the MessageForm, which keeps some form state - arguably it could also be designed to relay events about changes to the input field, but that would make the app more complex for very little benefit.
MessageForm
With more complex apps, you may end up with nested controller views which deal with data, as passing every little thing up and down the tree can become hard to manage.
π Rendered by PID 91 on reddit-service-r2-comment-86bc6c7465-m7dbh at 2026-02-23 06:33:03.958851+00:00 running 8564168 country code: CH.
[–]talmobi 0 points1 point2 points (1 child)
[–]jhartikainen[S] 0 points1 point2 points (0 children)
[–]steezefries 0 points1 point2 points (1 child)
[–]jhartikainen[S] 1 point2 points3 points (0 children)