Is there a way I can pass a parameter value into a function and use it as properties of an object?
const state = {
name: 'xyz',
properties: 'abc'
}
...
const handleStuff = (properties:string) => {
const a = [...state.properties]
if (action.status == true)
{
//some code
return {
...state,
properties: a
}
} else {
//some code
return {
...state,
properties: a
}
}
}
properties, is it an array?{ [properties]: a }, but thenpropertiesmust be (or convert to) a string, and it will be one property despite its name. Better provide an example input and expected result.