-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait to render before promise is resolved. #129
Comments
Same issue here. Async connect renders components before returned promise is resolved. The app is initialized like that: import { ReduxAsyncConnect } from 'redux-connect';
import { BrowserRouter } from 'react-router-dom';
import ReactDOM from 'react-dom';
import { hot } from 'react-hot-loader';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'connected-react-router';
import 'babel-polyfill';
import routes from './routes';
import store, { history } from './store';
const root = <ReduxAsyncConnect routes={routes} />;
hot(module)(root);
ReactDOM.render((
<Provider store={store}>
<BrowserRouter>
<ConnectedRouter history={history}>
{root}
</ConnectedRouter>
</BrowserRouter>
</Provider>
), window.document.getElementById('react-view')); I tried to remove The reducer: import { reducer as reduxAsyncConnect } from 'redux-connect';
import { combineReducers } from 'redux';
import { reducer as formReducer } from 'redux-form';
import reducers from '../redux/reducers';
export default function createReducer() {
return combineReducers({
form: formReducer,
reduxAsyncConnect,
...reducers,
});
} Store configuration: const middlewares = [
thunkMiddleware,
sideEffectsMiddleware(),
apiMiddleware(),
routerMiddleware(history),
];
const enhancers = [
applyMiddleware(...middlewares),
window.devToolsExtension && __DEVTOOLS__ ? window.devToolsExtension() : f => f,
];
const store = createStore(
connectRouter(history)(createReducer()),
initialState,
compose(...enhancers),
); The redux-connect enhancer creation: const reduxAsyncConnect = asyncConnect([{
key: 'hey',
promise: async ({ store: { dispatch, getState } }) => {
await new Promise(r => setTimeout(r, 5000))
},
}]); So everything looks set up as described. There is the part of action log: [{
"type": "@@router/LOCATION_CHANGE",
"payload": {
"location": {
"pathname": "/login",
"hash": "",
"search": "?redirect=%2F",
"key": "q0k114"
},
"action": "REPLACE"
}
}, {
"type": "@redux-conn/LOAD",
"payload": {
"key": "hey"
}
}, {
"type": "@redux-conn/BEGIN_GLOBAL_LOAD"
}, {
"type": "@redux-conn/BEGIN_GLOBAL_LOAD"
}, {
"type": "@redux-conn/END_GLOBAL_LOAD"
}, {
"type": "@redux-conn/LOAD_SUCCESS",
"payload": {
"key": "hey"
}
}, {
"type": "@redux-conn/END_GLOBAL_LOAD"
},
...
|
Almost everything is looking just fine: actions are fired; store is updated with data returned by |
@finom @masureshho did you find a solution for this? We use server-side rendering on the initial load and |
@kc-beard I've written my own super-tricky solution (the company I work for doesn't do open-source, so I can't share code with you, unfortunately). The issue with redux-connect isn't solved so I just removed it from the project. |
I've the same issue as @finom mentioned, i.e. component wrapped with Packages versions:
|
make sure that you have resolved a list of routes - the module works by walking through the tree of components to be rendered, gathering statics (meaning that a component must be returned as one of . the top-level components from |
@AVVS We don't do code-splitting yet and I just removed all
When I realod page on
And when I go to some other page and then navigate back to
which is expected - i.e. |
well, make sure that
returns a promise. if its not a promise - it wont wait until this is finished |
@AVVS yes, it returns a promise. It worth nothing to say that I've faced this problem only after I've upgraded to RR v4 and |
Any alternatives to this library? |
@finom we are really waiting |
@asyncConnect does not keep the components render stalled before the promise is resolved. Is this because I am not doing the server-side rendering?
P.S I do not want server-side rendering. Does this work only for a client? Please help.
The text was updated successfully, but these errors were encountered: