Skip to content

Comment on Best practices for building large React applications

Comments

"If you find yourself duplicating/synchronizing state between a child and parent component, then move that state out of the child component completely."

I have exactly one exception to this rule and I would love is someone could provide a recommended way to not make it an exception. Debouncing. For example, if you have a input field that lets you type a number for pagination, debouncing the change of that value with the displayed copy of it.

This is implemented with a debounced input field type that uses props to get and update the value, but maintains it's own state for what is displayed. It uses `componentWillReceiveProps` to stay in sync.

EDIT:

After re-reading, it looks like the author uses this exact same exception for the "select". This is considered UI state and should be fine.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.