Closed Aziaev closed 5 years ago
Does it happen in development? Can you provide a minimal repro that shows this error?
@bugzpodder yes, it's happen on local dev.
I found that there is a function which named getUserRestrictions
and duplicate of this function with same name in other incorrect place. When I delete duplicate function, imports on third side files becoming undefined. Very strange.
@bugzpodder I found that it happen when I import store for getting state by getState
import store from './../core/store';
...
const getPerimissions = store.getState().app.permissions
...
And store looks like:
import { createBrowserHistory as createHistory } from 'history';
import { routerMiddleware } from 'react-router-redux';
import { applyMiddleware, compose, createStore } from 'redux';
import createSagaMiddleware from 'redux-saga';
import rootReducer from '../reducers';
import rootSaga from '../sagas';
export const history = createHistory();
const sagaMiddleware = createSagaMiddleware();
const enhancers = [];
const middlewares = [
sagaMiddleware,
routerMiddleware(history),
];
window.__REDUX_DEVTOOLS_EXTENSION__ = window.__REDUX_DEVTOOLS_EXTENSION__ || {};
if (process.env.NODE_ENV === 'development') {
const devToolsExtension = window.__REDUX_DEVTOOLS_EXTENSION__;
if (typeof devToolsExtension === 'function') {
enhancers.push(devToolsExtension());
}
}
const composedEnhancers = compose(
applyMiddleware(...middlewares),
...enhancers,
);
const store = createStore(
rootReducer,
composedEnhancers,
);
sagaMiddleware.run(rootSaga);
export default store;
I have no idea why.
Please provide a minimal repro on github. If you aren't able to publicly, I still suggest you try to produce one anyway because you'll likely find the root cause along the way when you start deleting code.
Also check for cyclic imports
Sorry, but I can't provide minimal repo.
If I import 'store' from my ../store/index
, it crushes by same reason. If I remove store from imports, it works without error.
Thanks anyway
Store runs sagas so it's expected that it would succeed after you remove store. Like I said, just creating a minimal repro for yourself might reveal the cause of this.
@bugzpodder that was cycled url. Sagas were taking urls from file which imports store, and store executes sagas.
Is this a bug report?
Not sure
Did you try recovering your dependencies?
I tried to delete node_modules, package-lock.json,
npm install
npm version 6.9.0
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
Environment Info:
package.json
Steps to Reproduce
I have issue with imports. My imported variable is a constant
NOTIFICATIONS_SERVICE
and it imported as undefined:exported from here:
also the
reducer
function is also exported as undefinedIn reducer I'm trying to console object NOTIFICATION_SERVICE which is defined above, and then I get
undefined
in console. This issue causes other issues by chain. I can't even import it anywhere.Expected Behavior
Should be defined and worked as expected
Should imported as is
Actual Behavior
Imported objects and functions are undefined
In reducer I'm trying to console object NOTIFICATION_SERVICE which is defined above, and then I get
undefined
in console. This issue causes other issues by chain. I can't even import it anywhere. Screen shot:Stack trace in browser:
Part of bundle code:
(Write what happened. Please add screenshots!)
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)