diff --git a/examples/counter/package.json b/examples/counter/package.json index 86e10a82..d7254fad 100644 --- a/examples/counter/package.json +++ b/examples/counter/package.json @@ -5,6 +5,7 @@ "dependencies": { "@ice/store": "^1.3.4", "react": "^16.8.6", + "react-app-polyfill": "^1.0.6", "react-dom": "^16.8.6" }, "devDependencies": { @@ -23,12 +24,14 @@ "production": [ ">0.2%", "not dead", - "not op_mini all" + "not op_mini all", + "ie 11" ], "development": [ "last 1 chrome version", "last 1 firefox version", - "last 1 safari version" + "last 1 safari version", + "ie 11" ] } } \ No newline at end of file diff --git a/examples/counter/src/index.tsx b/examples/counter/src/index.tsx index de0a0689..9d612d47 100644 --- a/examples/counter/src/index.tsx +++ b/examples/counter/src/index.tsx @@ -1,6 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { createStore } from '@ice/store'; +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time)); @@ -8,8 +10,8 @@ const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), tim const counter = { state: 0, reducers: { - increment:(prevState) => prevState + 1, - decrement:(prevState) => prevState - 1, + increment: (prevState) => prevState + 1, + decrement: (prevState) => prevState - 1, }, effects: () => ({ async asyncDecrement() { @@ -29,7 +31,7 @@ const store = createStore(models); // 3️⃣ Consume model const { useModel } = store; function Counter() { - const [ count, dispatchers ] = useModel('counter'); + const [count, dispatchers] = useModel('counter'); const { increment, asyncDecrement } = dispatchers; return (
diff --git a/package.json b/package.json index 3299a76a..7252d544 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ice/store", - "version": "1.4.1", + "version": "1.4.2", "description": "Simple and friendly state for React", "main": "lib/index.js", "files": [ @@ -72,4 +72,4 @@ "redux": "^4.0.5", "redux-thunk": "^2.3.0" } -} +} \ No newline at end of file diff --git a/src/plugins/immer.ts b/src/plugins/immer.ts index 83fdc10c..ee71fa39 100644 --- a/src/plugins/immer.ts +++ b/src/plugins/immer.ts @@ -1,13 +1,16 @@ -import produce from 'immer'; +import produce, { enableES5 } from 'immer'; import { combineReducers, ReducersMapObject } from 'redux'; import * as T from '../types'; +// make it work in IE11 +enableES5(); + export interface ImmerConfig { blacklist?: string[]; } function createCombineReducersWithImmer(blacklist: string[] = []) { - return function(reducers: ReducersMapObject) { + return function (reducers: ReducersMapObject) { const reducersWithImmer: ReducersMapObject> = {}; // reducer must return value because literal don't support immer