代码:
import { CustomInput } from 'reactstrap'
...
const changeMediaStatus = (e) => {
console.log(e)
}
...
<CustomInput
type="switch"
className="ml-auto mr-1"
onChange={(e) =>changeMediaStatus(e)}
/>
在上述代码上;onChange;道具坏了。而且,带有onChange道具的CustomInput组件也不起作用。
如何在reactstrap CustomInput组件中为onChange事件分配函数?
为CustomInput提供id
。
<CustomInput
type="switch"
id="id-1"
className="ml-auto mr-1"
onChange={(e) => changeMediaStatus(e)}
/>
https://stackblitz.com/edit/reactstrap-1ttkao?file=Example.js