-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'apply' of undefined #2359
Comments
@four-eyes-04-04 That's because you should pass to compose only functions. But with falsy redux extension you pass false and compsoe trying to call apply of false. |
We had a "strip out falsy values" check in I'm not sure why there's a difference in behaviors between browsers, but yes, |
It's done, thanks. |
Just ran into this error by doing the following:
Which to me is a lot neater than the alternative I've found of replacing the entire compose function based upon that ternary instead. Is there a better way to do this? |
You can use this instead: import { composeWithDevTools } from 'redux-devtools-extension/developmentOnly'; |
I was having this issue as well. @markerikson's solution worked for me. In my case, I'm using both redux-thunk and redux-logger. I replaced "compose" with "composeWithDevTools" and it worked; import {createStore, applyMiddleware} from 'redux';
import rootReducer from '../reducers/rootReducer';
import thunk from 'redux-thunk';
import {composeWithDevTools} from 'redux-devtools-extension/developmentOnly';
import {createLogger} from 'redux-logger';
const logger = createLogger({
/* https://github.com/evgenyrodionov/redux-logger */
collapsed: true,
diff: true
});
const configureStore = function (initialState) {
return createStore(
rootReducer,
initialState,
composeWithDevTools(
/* logger must be the last middleware in chain to log actions */
applyMiddleware(thunk, logger)
)
);
}
export default configureStore; |
Had this error when running in a browser without the devtools extension. Fixed once I installed it. Now to make it work without... |
This is what worked for me (just replace devTools with a simple function onto itself in production)
|
I had hit this same error this morning. Yesterday, I was working on my home computer that I had added the redux-devtools extension added to Chrome already, but it turns out that on my work computer, I hadn't added it to Chrome yet. The error went away as soon as I added redux-devtools to the browser. |
|
I commented DEV TOOLS from store and it started working. I work in secure ODC so they dont allow me to install any chrome plugin
|
same here. It works also if you comment out applyMiddleware and leave teh devtools |
For anybody running in the same problem, I got this error because I had the devtools extension disabled in Chrome. Instead of using |
Had this issue only when testing so to keep devtools in production I did this: const devtools = process.env.NODE_ENV === 'test'
? x => x /* eslint-disable no-underscore-dangle */
: window.__REDUX_DEVTOOLS_EXTENSION__
&& window.__REDUX_DEVTOOLS_EXTENSION__();
/* eslint-enable no-underscore-dangle */
const store = createStore(
rootReducer,
compose(
applyMiddleware(thunk),
devtools,
),
); |
@johnazre You saved the day!!! I could not figure out whats wrong until i see that I dint install the redux dev tools. |
Solved this with just spread and ternary operators, maybe someone else will like this approach: export const createAppStore = (initialState = {}) => {
const middleware = [
applyMiddleware(thunkMiddleware),
...(window.__REDUX_DEVTOOLS_EXTENSION__ ? [window.__REDUX_DEVTOOLS_EXTENSION__()] : [])
]
const store = createStore(
rootReducer,
initialState,
compose(...middleware)
)
return store
} |
@kirankumarrr this error will always be thrown if you haven't instealled the redux dev tools. You have to explicit allow extension in incognito mode, if not they will be deacti Or just build in a conditional that falls back to the normal compose method so it works when Redux Dev Tools are not installed:
|
compose( |
So I am building a website. When I use a regular browser like google chrome everything works as expected, then I used blisk I got an error saying
app.js:14868 Uncaught TypeError: Cannot read property 'apply' of undefined(…)
I don't know what's going on but when I looked atline 14868
this is what I saw.any idea as to how to fixed this?
this is the store that is using the compose function btw.
using:
The text was updated successfully, but these errors were encountered: