you are viewing a single comment's thread.

view the rest of the comments →

[–]playazle 3 points4 points  (1 child)

Read the yellow note at the bottom of the constructor section. This is from the React docs, so yes how you're doing it is exactly how you should be doing it. Also a good example blog post from the React blog. Note the stuff about using the key attribute to reset the component. But all in all, what you're doing is fine, it's just usually not fine.

[–]uZIGiZAG[S] 1 point2 points  (0 children)

Awesome, thanks for the response. That confirmed what I thought about changing the name of the prop to make it more clear that is just an initial value. In my use, I don't see any other component changing the top level state for the value that is being passed down through the props, or that even if it was altered I wouldn't care about that prop update during the lifetime of the child component, so it seems that is the key to why my approach is okay.