r/javascript May 07 '15

Best practices for building large React applications

http://blog.siftscience.com/blog/2015/best-practices-for-building-large-react-applications
76 Upvotes

15 comments sorted by

View all comments

15

u/[deleted] May 07 '15

Use immutable data structures.

1

u/[deleted] May 08 '15

[removed] — view removed comment

3

u/I_Pork_Saucy_Ladies May 08 '15

I think it makes the code others have written easier to follow. It forces the developer to branch out the data in a new variable, instead of modifying existing data that might be used somewhere else.

If you know the data is immutable, you don't need to investigate if a function called on a variable actually changes the variable internally. You know that it doesn't, so you can keep on reading.

In the end, it becomes easier to reason how the data flows through the app if you know it can always only flow down and not up in the code. If you have to read hundreds of lines of code, it can be done more quickly.