()
| 4 | import { getSelectedComponentId } from '~core/selectors/components' |
| 5 | |
| 6 | export const useForm = () => { |
| 7 | const dispatch = useDispatch() |
| 8 | const componentId = useSelector(getSelectedComponentId) |
| 9 | |
| 10 | const setValueFromEvent = ({ |
| 11 | target: { name, value }, |
| 12 | }: ChangeEvent<HTMLSelectElement | HTMLInputElement>) => { |
| 13 | setValue(name, value) |
| 14 | } |
| 15 | |
| 16 | const setValue = useCallback( |
| 17 | (name: string, value: any) => { |
| 18 | dispatch.components.updateProps({ |
| 19 | id: componentId, |
| 20 | name, |
| 21 | value, |
| 22 | }) |
| 23 | }, |
| 24 | [componentId, dispatch.components], |
| 25 | ) |
| 26 | |
| 27 | return { setValue, setValueFromEvent } |
| 28 | } |
no test coverage detected