What I need: a way of accessing a destructured (or spread?) parameter by name.
My code is as follows:
open = ({ title = "Confirm", subTitle, link = {} } = {}) => {
this.setState({ isVisible: true, ...params?? });
}
So basically I'm receiving a single object with properties a,b,c
having default values for properties a,c
.
After this, I want to spread the received object into my state (or for any other purpose). But.. I don't know what to spread..
So let's assume I'm trying to call it params
as in the example.
What I tried:
open = (params : { title = "Confirm", subTitle, link = {} } = {}) => {
^ Unexpected token error
open = ({ title = "Confirm", subTitle, link = {} } = {} : params) => {
^ , expected
this.setState({ isVisible: true, ...arguments });
(attempt to access ES5 arguments
object)
^'arguments' is not allowed in class field initializer' error
Is there any way of achieving this?