Answer a question

I'm trying to build my app (using Redux and electron) with : yarn build

I get this error on Windows :

Property 'REDUX_DEVTOOLS_EXTENSION_COMPOSE' does not exist on type 'Window & typeof globalThis'

the error is in this block of code that I use for the configuration of Redux :

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
export const store = createStore( persistedReducer,
 composeEnhancers(applyMiddleware(thunkMiddleware))
);

how can I correct it ?

Answers

As you are using TS when you are trying to access a property on window that doesn't exist in Window type declaration. The compiler will error. There are several things you can do, you can try to use @ts-ignore so the compiler doesn't error or you can make extend window declaration with new property. Also you can try to do it like that: <any>window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ or window as any if you are using .tsx

Logo

React社区为您提供最前沿的新闻资讯和知识内容

更多推荐