Is possible to listen on Redux @@INIT action in middleware
Asked Answered
D

1

8

In Redux, there is initial action @@INIT.

Is possible to dispatch another action (in middleware) when this action occurred?

If not, what is best alternative to push action after store is ready?

Dejesus answered 19/6, 2017 at 8:45 Comment(0)
D
13

According to https://github.com/reactjs/redux/issues/186

@@INIT

  • internal action
  • name of that action may differ in dev mode, so if you use it - it might broke app functionality or automatic reloading
  • to sum-up, this action should not be touched in app codebase

How to push initial Redux actions then?

Without library:

const store = createStore(...);
store.dispatch(...)

In middleware like Redux Saga:

function * initialSaga() {
   yield put({ ... })
}
export default function * root() {
   yield fork(initialSaga);
}
Dejesus answered 19/6, 2017 at 8:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.