Answer the question
In order to leave comments, you need to log in
How to set the type of a function parameter?
[CHANGE_THEME]: (state: stateProps, { payload }): stateProps => ({
...state,
...payload,
}),
Answer the question
In order to leave comments, you need to log in
It can be like this -
interface StateProps {
a: number;
b: string;
c: boolean;
}
interface Action<P> {
payload: Partial<P>;
}
const f = <P>(state: P, { payload }: Action<P>): P => ({
...state,
...payload,
});
let nextState = f(
{ a: 0, b: '', c: true },
{ payload: { c: false } }
);
.tsx
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question