【发布时间】:2018-03-14 09:59:15
【问题描述】:
我有一个前端是用 react 和 redux 编写的 web 应用程序,这是我的 index.jsx 文件
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { createStore, applyMiddleware, compose } from 'redux';
import App from './app/App';
import Home from './app/Home';
import ContactMe from './app/ContactMe';
import ErrorPage from './app/ErrorPage';
import Post from './app/Post';
import makeRootReducer from './reducers/index';
require('./assets/stylesheets/bootstrap.scss');
require('./assets/stylesheets/styles.scss');
let store = null;
const middleware = applyMiddleware(thunk);
const enhancer = compose(
middleware,
window.__REDUX_DEVTOOLS_EXTENSION__ && compose
);
store = createStore(
makeRootReducer(),
{},
enhancer
);
ReactDOM.render(
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/" component={App} >
<IndexRoute component={Home} />
<Route path="contact-me" component={ContactMe} />
<Route path="post/:id" component={Post} />
<Route path="*" component={ErrorPage} />
</Route>
</Router>
</Provider>, document.getElementById('root'));
目前这个网络应用可以在 chrome 上运行,但不能在 Safari 上运行。
TypeError: undefined is not an object (evaluating 'b.apply')
这是我从 safari 得到的错误。 我发现如果我删除如下一行代码
window.__REDUX_DEVTOOLS_EXTENSION__ && compose
它在 chrome 和 safari 上都能正常工作,但我不能使用 redux 开发工具。 如果我将 && 更改为 || (如下所示,它适用于 safari 但不适用于 chrome
window.__REDUX_DEVTOOLS_EXTENSION__ || compose
任何人都可以弄清楚我的代码有什么问题。因为我需要使用开发工具来跟踪 web 应用程序的状态并在 chrome 和 safari 上运行它
【问题讨论】:
-
不是你想要的,但this 可能会有所帮助。
标签: reactjs redux react-redux redux-thunk react-router-redux