skip to Main Content

I have a form component and i need to use react context to manage and validate each input seperetly because i build an input component, and i build a component contain information from the form component , can react context treat each input individually or not , or use redux

Do React Context like useState , In the treatment of the components, each one is treated separately or not

2

Answers


  1. Yes, you can use React Context to manage and validate each input separately in your form component. React Context allows you to share data and state across multiple components without having to pass props manually through each level of the component tree.

    To treat each input individually, you can create a separate context for each input field. Each input component can consume its respective context to manage its state and handle validation

    Login or Signup to reply.
  2. React context is in fact passing data with props through multiple level but without the need of implementing this. so in your case it is like you pass the whole state in which you store the inputs to each child component and use it there.

    better is to pass to each child component directly as props the data it needs.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search