-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Following the example for useDidChange from the README doesn't seem to work. It looks like there might be a type mismatch. 🤔
The null we can easily fix with prevProps?.[0].value !== props.value, it's the callback not matching that I'm stuck on.
export const Example: React.FC<{ value: number }> = (props) => {
// Called when dependencies change, we can inspect previous dependencies
useDidChange(
// Argument of type '(prevProps: PropsWithChildren<{ value: number; }>[] | null) => void' is not assignable to parameter of type 'VoidFunction | ((previousDependencies: PropsWithChildren<{ value: number; }>[] | null) => VoidFunction)'.
// Type '(prevProps: PropsWithChildren<{ value: number; }>[] | null) => void' is not assignable to type 'VoidFunction'.
// Target signature provides too few arguments. Expected 1 or more, but got 0.
// @ts-expect-error
(prevProps) => {
// 'prevProps' is possibly 'null'
// @ts-expect-error
if (prevProps[0].value !== props.value) {
// ...
}
},
[props],
true
);
return <div>Test..</div>;
};Metadata
Metadata
Assignees
Labels
No labels