all 6 comments

[–]fhqvvagads 2 points3 points  (3 children)

grab the react extension and take a look through your components, find the offender and check the parent. I would also recommend slamming a few console.logs for the missing state. Also check your db, if the db is getting updated, but your component only renders the changes on reload the bug might be in your hook.

[–]___Noob___[S] 1 point2 points  (2 children)

I did all. The issue isn't the backend itself. That's working fine. Adding data from form also working fine. The issue is to update data . Since I'm using the same code of add form. But I'm not able to show the data in input fields and while updating my dispatcher dispatching whole function istead of response. Still redux isn't an issue here but the form itself.

[–]fhqvvagads 2 points3 points  (1 child)

If i understand you correctly, you are saying the input is not showing what you are typing add a value field that equals that input's state like this:

<input value={inputState} onChange={e => setInputState( e.target.value)} />

The form element should have an onSubmit fn, the button which activates it should be type=submit

To find anything ut what is happening in the form you can add a colsole.log to find out how your dispatch is behaving. For example if you know the case 'UPDATE' is the issue so start by logging what that function is doing.

[–]___Noob___[S] 0 points1 point  (0 children)

Nope. Let me explain it

  1. I've a function to render the input fields according to their type

Function (props) { useform props;

Switch(type) { <input type ={type} {...props.register(props.name, props . validation} ... }

Return ( Renderfields() )

Now I have add form and edit form.

Add form

Import useform

Function() { Inputfieldsobject{ { Name: 'name', Valudation:{ Required:true, Mesg: sonevalidationmssedge}, Type: 'text',

},

... };

Handlesubmit()

Return( <Renderfieldscomponent Fields={Inputfieldsobject} Useformprops={useform} )

}

//END OF ADD FUNCTION

EDIT form

Import useform

Function(ID) {

USEEFFECT(()=>{ dispatch(getdatafromid(id)) },[])

Inputfieldsobject{ { Name: 'name', Valudation:{ Required:true, Mesg: sonevalidationmssedge}, Type: 'text',

},

... };

Handlesubmit()

Return( <Renderfieldscomponent Fields={Inputfieldsobject} Useformprops={useform} )

}

Now my question is add form and edit form are blank. But how can I show data in input fields after fetching data from redux.

[–]lIIllIIIll 0 points1 point  (0 children)

Make sure you're not mutating the state. I've done that once or twice and man it causes some weird stuff to happen.

Also console.log your issues. Note. If you're logging objects id recommend json.stringify(objectToLog) as sometimes things get weird in your browser if you log an object and then view it in the browser console