Mencoba untuk mendapatkan react-router (v4.0.0) dan react-hot-loader (3.0.0-beta.6) untuk bermain dengan baik, tetapi mendapatkan kesalahan berikut di konsol browser:
Peringatan: React.createElement: type is invalid - diharapkan string (untuk komponen built-in) atau class / function (untuk komponen komposit) tetapi got: undefined. Anda mungkin lupa mengekspor komponen Anda dari file yang ditentukan di dalamnya.
index.js:
import React from 'react';
import ReactDom from 'react-dom';
import routes from './routes.js';
require('jquery');
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap/dist/js/bootstrap.min.js';
import './css/main.css';
const renderApp = (appRoutes) => {
ReactDom.render(appRoutes, document.getElementById('root'));
};
renderApp( routes() );
routes.js:
import React from 'react';
import { AppContainer } from 'react-hot-loader';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import store from './store/store.js';
import { Provider } from 'react-redux';
import App from './containers/App.jsx';
import Products from './containers/shop/Products.jsx';
import Basket from './containers/shop/Basket.jsx';
const routes = () => (
<AppContainer>
<Provider store={store}>
<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component={Products} />
<Route path="/basket" component={Basket} />
</Route>
</Router>
</Provider>
</AppContainer>
);
export default routes;
component
properti daripadarender
, karena paket tidak mendukung nanti. Lihat lebih lanjut di GitHub .