I have been scattering the internet in search of an answer but my guess is that what i am doing is either wrong or i don't know the right therm because i can't find any relevant answer. Long story short, i want to pass a condition to a state value that is based on another state value inside the constructor. Why? Because i am building a "Form Generator" and i want to be able to link an input to another one. Exemple : If a checked box is checked, then you can enter text inside a text input otherwise it is disabled. Pretty simple right? If anybody can just point me in a direction that would be great. So far this is what i have tried but it doesn't work.
constructor(props){
this.state =
Inputs : [
//Theres a bunch of inputs here
{
name : "Icon",
group: 1,
width: 6,
type: "select",
label: "Icon du menu",
disabled: () =>(
!this.state.Inputs[0].value //I want to link the disable property to an
//input value
),
value: ""
}
]
}
I have also tried to create a constraint object in my state and iterate trough the value during the mounting process but i found it to be too fragile and time consuming. If i could directly create the link inside the input object that would be great.
Thanks for your time and great wisdom!
-Sam
Aucun commentaire:
Enregistrer un commentaire