Redux: 'break' statement missing from switch statements in basics/reducers

Created on 18 May 2018  路  2Comments  路  Source: reduxjs/redux

Documentation bug

Example code at https://redux.js.org/basics/reducers has switch statements without breaks.

What is the current behavior?

The actual behaviour of the example code is that nothing happens for any given action - the execution flows all the way through to the default case no matter what action is supplied.

What is the expected behavior?

With break statements added, the correct action is applied to the reducer. That means the state correctly changes after each action is dispatched.

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?

This is just a minor javascript mistake, so hopefully versions are not relevant. I have never submitted a pull request before, so I thought I'd bring up the issue here first. Should I supply a pull request with a fix for the problem?

Thanks!

Most helpful comment

The switch cases all use return statements, so a break isn't necessary.

All 2 comments

The switch cases all use return statements, so a break isn't necessary.

Ah yes. I changed the code to assign a variable instead of returning while I was playing with it, and then forgot about it. Sorry about that!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vraa picture vraa  路  3Comments

ilearnio picture ilearnio  路  3Comments

ms88privat picture ms88privat  路  3Comments

captbaritone picture captbaritone  路  3Comments

vslinko picture vslinko  路  3Comments