How do you say that props are read-only?

  • By using Object.freeze()
  • By using Object.preventExtensions()
  • By using Object.seal()
  • By not modifying them directly
In React, props are read-only and should not be modified directly. Attempting to modify props directly can cause bugs and make components unpredictable. Instead, components should create and maintain their own state to manage changes to data.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *