Redux-toolkit: Counter Vanilla example broken

Created on 29 Dec 2019  路  3Comments  路  Source: reduxjs/redux-toolkit

The counter vanilla example does not work when viewed on codesandbox or when downloaded locally (macos, tried Chrome/Firefox/Safari). Page loads, but an error message about 'require' being undefined is thrown, buttons don't update or change the state in any way.

Locally, I managed to fix the issue by changing:

<script src="https://unpkg.com/@reduxjs/toolkit@latest/dist/redux-toolkit.umd.js"></script>

to

<script src="https://unpkg.com/@reduxjs/toolkit@latest/dist/redux-toolkit.umd.min.js"></script>

Not sure if the codesandbox demo is supposed to be interactive, but I feel like it should be. The same fix didn't work there though.

Hopefully this is all clear, let me know if any further info is needed.

Most helpful comment

Hey, thank you for this report. This is indeed a bundling issue.

https://unpkg.com/@reduxjs/toolkit@1.2.1/dist/redux-toolkit.umd.js should not contain

      /* PROD_START_REMOVE_UMD */
      var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"];

      var immutableOptions = {};

      if (!isBoolean(immutableCheck)) {
        immutableOptions = immutableCheck;
      }

      middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
      /* PROD_STOP_REMOVE_UMD */

This seems to be a regression due to #280. I'll ping the author over there.

All 3 comments

Hey, thank you for this report. This is indeed a bundling issue.

https://unpkg.com/@reduxjs/toolkit@1.2.1/dist/redux-toolkit.umd.js should not contain

      /* PROD_START_REMOVE_UMD */
      var createImmutableStateInvariantMiddleware = require('redux-immutable-state-invariant')["default"];

      var immutableOptions = {};

      if (!isBoolean(immutableCheck)) {
        immutableOptions = immutableCheck;
      }

      middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
      /* PROD_STOP_REMOVE_UMD */

This seems to be a regression due to #280. I'll ping the author over there.

@phryneas Hi apologies for the lack of communication over the holidays.
Will take a look at this tonight

This is fixed now that 1.2.2 is out.

Was this page helpful?
0 / 5 - 0 ratings