Skip to content

Commit 3c816d8

Browse files
committed
inject reducers
1 parent b089c2a commit 3c816d8

File tree

6 files changed

+14
-15
lines changed

6 files changed

+14
-15
lines changed

src/containers/ChatFeathers/ChatFeathers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import { provideHooks } from 'redial';
44
import { connect } from 'react-redux';
5-
import * as chatActions from 'redux/modules/chat';
5+
import reducer, * as chatActions from 'redux/modules/chat';
66
import { withApp } from 'hoc';
77

88
@provideHooks({
9-
fetch: ({ store: { dispatch, getState } }) => {
9+
fetch: async ({ store: { dispatch, getState, inject } }) => {
10+
inject({ chat: reducer });
11+
1012
const state = getState();
1113

1214
if (state.online) {

src/containers/Survey/Survey.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
3+
import { provideHooks } from 'redial';
34
import { connect } from 'react-redux';
45
import Helmet from 'react-helmet';
56
import { initialize } from 'redux-form';
7+
import reducer from 'redux/modules/survey';
68
import SurveyForm from 'components/SurveyForm/SurveyForm';
79

10+
@provideHooks({
11+
fetch: ({ store: { inject } }) => inject({ survey: reducer })
12+
})
813
@connect(() => ({}), { initialize })
914
export default class Survey extends Component {
1015
static propTypes = {

src/containers/Widgets/Widgets.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import PropTypes from 'prop-types';
33
import Helmet from 'react-helmet';
44
import { provideHooks } from 'redial';
55
import { connect } from 'react-redux';
6-
import * as widgetActions from 'redux/modules/widgets';
6+
import reducer, * as widgetActions from 'redux/modules/widgets';
77
import WidgetForm from 'components/WidgetForm/WidgetForm';
88

99
const { isLoaded, load: loadWidgets } = widgetActions;
1010

1111
@provideHooks({
12-
defer: ({ store: { dispatch, getState } }) => {
12+
defer: ({ store: { dispatch, getState, inject } }) => {
13+
inject({ widgets: reducer });
14+
1315
if (!isLoaded(getState())) {
1416
return dispatch(loadWidgets()).catch(() => null);
1517
}

src/redux/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import createReducers from './reducer';
77
export function inject(store, reducers) {
88
Object.entries(reducers).forEach(([name, reducer]) => {
99
if (store.asyncReducers[name]) return;
10-
store.asyncReducers[name] = reducer;
10+
store.asyncReducers[name] = reducer.__esModule ? reducer.default : reducer;
1111
});
1212

1313
store.replaceReducer(combineReducers(createReducers(store.asyncReducers)));

src/redux/reducer.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import auth from './modules/auth';
55
import notifs from './modules/notifs';
66
import counter from './modules/counter';
77
import info from './modules/info';
8-
import widgets from './modules/widgets';
9-
import survey from './modules/survey';
10-
import chat from './modules/chat';
118

129
export default function createReducers(asyncReducers) {
1310
return {
@@ -22,9 +19,6 @@ export default function createReducers(asyncReducers) {
2219
counter3: counter
2320
}),
2421
info,
25-
widgets,
26-
survey,
27-
chat,
2822
...asyncReducers
2923
};
3024
}

src/routes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { routerActions } from 'react-router-redux';
44
import { connectedReduxRedirect } from 'redux-auth-wrapper/history4/redirect';
55
import { App, Home, NotFound } from 'containers';
66

7-
/* eslint-disable react/prop-types */
8-
97
const About = Loadable({
108
loader: () => import('./containers/About/About'),
119
loading: () => <div>Loading</div>
@@ -46,8 +44,6 @@ const Widgets = Loadable({
4644
loading: () => <div>Loading</div>
4745
});
4846

49-
/* eslint-enable react/prop-types */
50-
5147
const isAuthenticated = connectedReduxRedirect({
5248
redirectPath: '/login',
5349
authenticatedSelector: state => state.auth.user !== null,

0 commit comments

Comments
 (0)