Skip to content

Commit

Permalink
Change getContextValue for setContextValue
Browse files Browse the repository at this point in the history
  • Loading branch information
WiXSL committed May 15, 2023
1 parent 15f0bce commit caf4d46
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/ra-core/src/form/useInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ const Input: FunctionComponent<
const InputWithCustomOnChange: FunctionComponent<
{
children: (props: ReturnType<typeof useInput>) => ReactElement;
} & InputProps & { getContextValue?: (value: string) => void }
> = ({ children, getContextValue, ...props }) => {
} & InputProps & { setContextValue?: (value: string) => void }
> = ({ children, setContextValue, ...props }) => {
const { getValues } = useFormContext();

return (
<Input
{...props}
onChange={e => {
props.onChange(e);
getContextValue(getValues()[props.source]);
setContextValue(getValues()[props.source]);
}}
>
{children}
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('useInput', () => {
const handleChange = e => {
targetValue = e.target.value;
};
const getContextValue = value => {
const setContextValue = value => {
contextValue = value;
};

Expand All @@ -142,7 +142,7 @@ describe('useInput', () => {
source="title"
resource="posts"
onChange={handleChange}
getContextValue={getContextValue}
setContextValue={setContextValue}
defaultValue=""
>
{({ id, field }) => (
Expand Down

0 comments on commit caf4d46

Please sign in to comment.