addListener
giving type error wrt actionCreator
#5030
Answered
by
EskiMojo14
SansPapyrus683
asked this question in
Q&A
-
I have the following code inside of a React component: const dispatch = useDispatch<AppDispatch>();
useEffect(() => {
return dispatch(
addListener.withTypes<RootState, AppDispatch>()({
actionCreator: setFindWindowOpen,
effect: (action) => {
// ...
},
})
);
}, [dispatch]); But I'm getting the following error: I know someone was having a similar problem here, but I believe this is different as the target type is just straight up |
Beta Was this translation helpful? Give feedback.
Answered by
EskiMojo14
Jul 9, 2025
Replies: 1 comment 6 replies
-
Does anything change if you save the const addTypedListener = addListener.withTypes<RootState, AppDispatch>();
function MyComponent() {
const dispatch = useDispatch<AppDispatch>();
useEffect(() => {
return dispatch(
addTypedListener ({
actionCreator: setFindWindowOpen,
effect: (action) => {
// ...
},
})
);
}, [dispatch]);
} |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
export const findSlice: Slice<FindState> =
never do this
you are throwing away all of the information it knows about your slice
remove the type annotation and everything should be a lot happier