Created
August 13, 2018 13:18
-
-
Save toruticas/9faf584d97bfbaf2bc63b42aaa25364c to your computer and use it in GitHub Desktop.
Real world bug modifying reference argument in a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { init } from "@rematch/core" | |
import * as models from "./models" | |
import * as reducers from "./reducers" | |
import { syncInitialStatePlugin } from "./plugins" | |
function initStore(initialStateModel ,initialStateRedux) { | |
store = init({ | |
models: models, | |
plugins: [syncInitialStatePlugin(initialStateModel)], | |
redux: { | |
initialStateRedux, | |
middlewares: [thunkMiddleware], | |
reducers: reducers, | |
}, | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const syncInitialStatePlugin = (state = {}) => ({ | |
init: () => ({ | |
onModel(model) { | |
model.state = state[model.name] | |
}, | |
}), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment