我想将父状态从子状态更改为
export const ParentComponent=()=>{
const [ resendCodeStatus ,setResendCodeStatus ] = useState(false)
const callback=()=>{
setResendCodeStatus(!resendCodeStatus)
}
return (
< Timer callback={callback} />
)
}但是我只能访问回调函数一次。
发布于 2021-01-15 10:17:31
试试这个:
export const ParentComponent=()=>{
const [ resendCodeStatus ,setResendCodeStatus ] = useState(false)
const callbackFunction=()=>{
setResendCodeStatus((status) => !status)
}
return (
<Timer callbackFunction={callbackFunction} />
) }https://stackoverflow.com/questions/65734072
复制相似问题