OnChange Is Not Working in Reactstrap Custom Input Switch

OnChange Is Not Working in Reactstrap Custom Input Switch

Code:

import { CustomInput } from 'reactstrap'
...
const changeMediaStatus = (e) => {
   console.log(e)
}
...
<CustomInput
   type="switch"
   className="ml-auto mr-1"
   onChange={(e) =>changeMediaStatus(e)}
/>

On the above code, the function that is assigned at "onChange" prop is not working. And also, CustomInput component with onChange prop is not working.

How can I assign a function to onChange event at reactstrap CustomInput compoenent?

3

1 Answer

Provide id for the CustomInput.

<CustomInput
      type="switch"
      id="id-1"
      className="ml-auto mr-1"
      onChange={(e) => changeMediaStatus(e)}
    />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.