Пишу как по документации:
App.js:
import React, {Component, PropTypes} from 'react';
import {render} from 'react-dom';
import {combineReducers, createStore} from 'redux';
import {connect} from 'react-redux';
import players from "./reducers/players_reduce";
import order from "./reducers/order_reduce";
import steps from "./reducers/steps_reduce";
import fields from "./reducers/fields_reduce";
import chip from "./reducers/chip_reduce";
import current_player from "./reducers/current_player_reduce";
import reload from "./reducers/reload_reduce";
import initialState from "./initialState";
let rootReducer = combineReducers({
players, order, steps, fields, chip, current_player, reload
});
let store = createStore(rootReducer, initialState);
class App extends Component {
constructor(props) {
super(props);
this.props = props;
}
render() {
return (<div>
{this.props.children};
</div>);
}
};
export default connect(store)(App);
export {store};
index.js:
import React, {Component} from 'react';
import {render} from 'react-dom';
import {createStore} from 'redux';
import {Provider} from 'react-redux';
import ReactIgnore from './ReactIgnore';
import App, {store} from './App';
render(
<Provider store={store}>
<App/>
</Provider>,
document.getElementById('root')
);
Выдает:
Uncaught Error: _registerComponent(...): Target container is not a DOM element.
Но если пробую написать в App.js так:
export default connect(store)(render(App, document.getElementById("AppRoot")));
export {store};
<div id="AppRoot"></div>
Находится в index.html.
То ожидаемо ругается:
Uncaught Error: ReactDOM.render(): Invalid component element. Instead of passing a class like Foo, pass React.createElement(Foo) or .
В чем дело? Подключение, по документации не хочет работать, а если рендерить для connect, то не оборачивается в
<Provider/>
.