Skip to content

The on function #3104

Discussion options

You must be logged in to vote

@lukhomdingi

on function is intended for use within the createReducer function. Then the type of action creators will be automatically inferred.

However, if you want to use on function separately, you can manually declare the type of action creator array:

export const onLoginSuccess = on<fromAuth.State, [typeof AuthApiActions.loginSuccess]>(
  AuthApiActions.loginSuccess,
  (state, { user }) => ({ ...state, user })
);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by markostanimirovic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants