You are not using the toggle which reflects the checking status. but you used value, which is never set.
import React from "react";
import Toggle from "react-toggle";
const OwnToggle = props => {
// here you have to use toggle, not value
const { toggle, path, toggleSwitchHandler } = props;
return (
<Toggle checked={toggle} onChange={e => toggleSwitchHandler(path, e)} />
);
};
export default OwnToggle;
And also you had to pass object instead of obj in App.js.
<FirstRow toggle={object} toggleSwitchHandler={toggleSwitchHandler} />
<SecondRow toggle={object} toggleSwitchHandler={toggleSwitchHandler} />
There should be a modification in your toggleSwitchHandler:
const toggleSwitchHandler = (path, e) => {
const tempObject = { ...object };
set(tempObject, path, !get(object, path)); // get from lodash
setObject({ ...object, ...tempObject });
};