Facebook Pixel

What is the single source of truth principle in React?

Each piece of data should have one owner. Do not duplicate data between props and state, or across stores. Duplication causes sync bugs when one copy updates and another does not.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in React State and Data Flow Interview Questions

Props are inputs from a parent, read-only in the child. State is internal data the component owns and can change, triggering re-renders. Props are external; state is internal.

When two or more siblings need the same data and must stay in sync. Lift it to their common parent, which owns the state and passes it down to both as props, creating a single source of truth.

Context for widely-shared, rarely-changed data like auth and theme. Redux for complex, frequently-updated shared state with many interactions. Reach for Redux only when Context is genuinely insufficient.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.