MCPcopy
hub / github.com/premieroctet/openchakra / useForm

Function useForm

src/hooks/useForm.ts:6–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { getSelectedComponentId } from '~core/selectors/components'
5
6export 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}

Callers 15

IconControlFunction · 0.90
GradientControlFunction · 0.90
SwitchControlFunction · 0.90
ChildrenControlFunction · 0.90
SizeControlFunction · 0.90
VariantsControlFunction · 0.90
NumberControlFunction · 0.90
TextControlFunction · 0.90
ColorPickerControlFunction · 0.90
CustomPropsPanelFunction · 0.90
CloseButtonPanelFunction · 0.90
CodePanelFunction · 0.90

Calls 1

useDispatchFunction · 0.85

Tested by

no test coverage detected