question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

t.apply is not a function

See original GitHub issue

Steps to reproduce

Configure my store like so, following the directions here:

import { applyMiddleware, compose, createStore } from 'redux'
import thunkMiddleware from 'redux-thunk'
...
if (window.__REDUX_DEVTOOLS_EXTENSION__) {
    middleware = [thunkMiddleware, window.__REDUX_DEVTOOLS_EXTENSION__()]
    const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
    const enhancer = composeEnhancers(applyMiddleware(...middleware))
    store = createStore(reducer, {}, enhancer)
}

Expected Behavior

Store is connected to both redux-thunk and redux devtools

Actual Behavior

Receive the error:

Uncaught (in promise) TypeError: t.apply is not a function
    at <anonymous>:3:4545
    at <anonymous>:3:985
    at <anonymous>:2:838
    at compose.js:29
    at applyMiddleware.js:41
    at <anonymous>:2:1425
    at createStore (createStore.js:51)
    at index.js:25
    at <anonymous>

Using:

  • React 16.0.0
  • Redux 3.7.2
  • Redux DevTools 2.15.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

19reactions
ktraffcommented, Oct 10, 2017

Was able to fix this by removing window.__REDUX_DEVTOOLS_EXTENSION__() from the list of enhancers. Looks like the composeEnhancers function will perform this step for me.

1reaction
ItsGoshocommented, Sep 26, 2019

This caused the error:

let calculatorStore = createStore( calculatorReducer, 0, applyMiddleware(loggingMiddleware,window.REDUX_DEVTOOLS_EXTENSION()) );

How @ktraff said ,we must use compose ,because we want to apply multiple ENCHANCERS:

Solution:

let calculatorStore = createStore( calculatorReducer, 0, compose(applyMiddleware(loggingMiddleware),window.REDUX_DEVTOOLS_EXTENSION()) );

Read more comments on GitHub >

github_iconTop Results From Across the Web

angularjs - t.apply is not a function - Stack Overflow
I can't see where to change the code as I'm not actually using a D3 function 'apply'. The Angular code has not changed...
Read more >
Callback.apply is not a function - The freeCodeCamp Forum
It means that there was a type error. Something in JS has “thrown” an error. It is saying, “When I evaluate 'callback.apply', what...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
Script Error: func.apply is not a function - Google Groups
The error occurs when a function call for the second time . The function loops through a list and count the occurrences of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found