如何在 ReactJS 钩子中使用箭头函数传递参数

How to pass params with arrow function in ReactJS hooks

我是 ReactJS 的新手,我对如何使用箭头函数传递参数感到困惑,我尝试使用 .bind() 绑定值,以便我可以在 function 但它不起作用,像普通函数一样传递它也不起作用。

我的代码

const getCheckById = (checkID) =>{
    console.log(checkID)
}

<div className=''>
    {
        // allChecks is an array of objects
        allChecks.map((el,index) => {
        return <div key ={index}>
                <span onClick={getCheckById(el.checkID)}>+</span>
            </div>
        })
    }
</div>
const getCheckById = (checkID) =>{
    console.log(checkID)
}


<div className=''>
    {
        // allChecks is an array of objects
        allChecks.map((el,index) => {
        return <div key ={index}>
                <span onClick={() => getCheckById(el.checkID)}>+</span>
            </div>
        })
    }
</div>