I want to do run a function and pass some parameters in my input value, but it's giving me this error:
Invalid value for prop
valueon <input> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM.
I remember reading somewhere once that you can use functions in value
, but this isn't working for me. Is there another way.
value={() => this.handleMapping(row.servername, "Data Source Server")}
Error: Invalid value for prop
valueon <input> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM.
You have provided an anonymous function here,
value={() => this.handleMapping(row.servername, "Data Source Server")}
Instead you need to just provide the function, which will execute when the component loads.
value={this.handleMapping(row.servername, "Data Source Server")}
Also make sure your handleMapping
function should return something which can be treated as input value.
Note: Also make sure to provide onChange
handler on input.