const mapStore = createStore(
rootReducer,
compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f,
)
);
и вот данные появляются быстрее в редюсере чем в инпутетак и должно быть.
case 'TOGGLE_COMPLETED':
return Object.assign({}, state, {
todo: state.todo.map((item) => {
if(item.id == action.id) {
item.completed = !item.completed
}
return item;
})
})
class MainComponent extends React.Component {
static propTypes = {
activeType: PropTypes.string,
}
static mapStateToProps(state) {
return {
activeType: state.sideBar.activeType,
};
}
// ....
export default connect(
MainComponent.mapStateToProps,
{})(MainComponent);
import { CHANGE_TYPE as SIDEBAR_CHANGE_TYPE } from '../SideBar/constants';
const initState = {
activeType: undefined,
};
export default (state = initState, action) => {
switch (action.type) {
case SIDEBAR_CHANGE_TYPE:
return {
...state,
activeType: action.payload,
};
// ....
default:
return state;
}
};
export default function (state = innitialState, action) {
switch (action.type) {
case 'SELECT__DATE':
return Object.assign({}, state, {
date: state.date + action.payload,
});
break;
}
}
export default function(ComposedComponent) {
class Authenticate extends React.Component {
componentWillMount() {
if (!localStorage.jwtToken) {
this.context.router.push('/auth');
}
}
componentWillUpdate(nextProps, nextState) {
if (!nextProps.isAuthenticated) {
this.context.router.push('/auth');
}
}
render() {
return (
<ComposedComponent {...this.props} />
);
}
}
Authenticate.propTypes = {
isAuthenticated: React.PropTypes.bool.isRequired,
};
Authenticate.contextTypes = {
router: React.PropTypes.object.isRequired,
};
function mapStateToProps(state) {
return {
isAuthenticated: state.auth.isAuthenticated,
};
};
return connect(mapStateToProps, { })(Authenticate);
}
<Route path="/main" component={requireAuth(MainPage)} />