The problem that the formal parameter of a function parameter is an object

Today, in React, the way components are written is how props is passed.

Sub-component A:

const A = ({arg1,arg2}) => {
    ...
}

parent component B:

const B = () => {
    <A arg1={method1} arg2={method2} />
}

Why are the function parameters in An enclosed in curly braces {} instead of being written as const A = (arg1,arg2) ?

Jul.29,2021

deconstruct

if you pass an object {arg1:1, arg2:2} , then the values of arg1 and arg2 of formal parameters will be assigned to 1,2

.

if you don't understand, please refer to

Previous: How to dynamically add responsive properties to vm instances in vuejs?

Next: How to customize the routing of php suffixes in ThinkPHP V5.1.18

Menu