I mean, they are more like events than state!
I would not say that. I think loading indicators are a great example of a UI that is easily described as a state function: in this case, a boolean variable. While this answer is correct, I would like to provide some code to go along with it.
In the async example in the Redux repository, the reducer updates a field called isFetching :
case REQUEST_POSTS: return Object.assign({}, state, { isFetching: true, didInvalidate: false }) case RECEIVE_POSTS: return Object.assign({}, state, { isFetching: false, didInvalidate: false, items: action.posts, lastUpdated: action.receivedAt
The component uses connect() from React Redux to subscribe to the state of stores and returns isFetching as part of the return value of mapStateToProps() so it is available in the details of the connected components:
function mapStateToProps(state) { const { selectedReddit, postsByReddit } = state const { isFetching, lastUpdated, items: posts } = postsByReddit[selectedReddit] || { isFetching: true, items: [] } return { selectedReddit, posts, isFetching, lastUpdated } }
Finally, the component uses isFetching prop in the render() function to display the label "Loading ..." (which may possibly be a spinner instead):
{isEmpty ? (isFetching ? <h2>Loading...</h2> : <h2>Empty.</h2>) : <div style={{ opacity: isFetching ? 0.5 : 1 }}> <Posts posts={posts} /> </div> }
Even the worst case, what should I do when I need to use the built-in confirmation dialog or warning dialog in redux / react applications? Where should they be placed, actions or gears?
Any side effects (and, apparently, dialogue, certainly a side effect) do not apply to reducers. Think of gearboxes as passive "state builders." They really don't "do" things.
If you want to show a warning, either do it from the component before sending any action, or do it from the creator of the action. By the time the action is dispatched, it is too late to perform side effects in response to it.
There is an exception for each rule. Sometimes your logic of side effects is so complex that you really want to connect them to either specific types of actions or specific reducers. In this case, check out advanced projects like Redux Saga and Redux Loop . Just do it when you are comfortable with vanilla Redux and you have the real problem of diffuse side effects that you would like to make more manageable.