Calling A Component From A Container And Rendering The Form Based On Input Parameters Given From Parent Container
Following is my code for Todo component where i am rendering my component named Dynamic component import React, { Component } from 'react'; import Dynamiccomponent from
Solution 1:
The following issue is because of not changing the state properly and updating it
I have changed the following lines of code in component did mount now it worked
componentDidMount(){
AxiosInstance.get('/todos').then((data) =>{
console.log("these is the data you have entered in db",data);
let dataFromServer = data.data.data.map((data) =>{
console.log(data);
Object.keys(this.state.Todo).map((proptype)=>{
console.log("////////////////////", this.state.Todo[proptype].value)
let StateKeyValue = this.state.Todo[proptype].value;
let dynamicValue = data[proptype];
console.log("[we are seeing the dynamic value before entering into the state]" , " ", StateKeyValue );
this.setState(prevState =>({
Todo : {...prevState.Todo, [proptype] : {... dynamicValue, value: dynamicValue } }
}))
})
})
Post a Comment for "Calling A Component From A Container And Rendering The Form Based On Input Parameters Given From Parent Container"