-
Notifications
You must be signed in to change notification settings - Fork 17
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
Redux support needed #15
Comments
Do you have an example of how would you envision this to work? |
Maybe something like this: import {Provider} from 'preact-redux';
import {applyMiddleware, createStore} from 'redux';
import { renderToString } from 'react-router-server';
...
let store = createStore(
rootReducer,
applyMiddleware(epicMiddleware)
);
renderToString(<Provider store={store}><App/></Provider>)
.then(({ html, state }) => {
// state here should actually be the redux-state at the end of all async operations.
}); and just the normal redux |
Would also be interested in knowing if this is in the works |
How would we know when all async operations are done in redux? Wouldn't it currently work with redux by doing something like this: import * as React from 'react';
import {fetchState} from 'react-router-server';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux'
@fetchState(
state => state,
actions => ({ done: actions.done })
)
@connect(
({ message }) => ({ message }),
dispatch => ({ actions: bindActionCreators(actionCreators, dispatch) })
)
class Example extends React.PureComponent {
componentWillMount() {
this.props.actions.loadSomeMessage()
.then((message) => this.props.done({ message }));
}
render() {
return (
<div>{this.props.message || 'Loading...'}</div>
);
}
}
export default Example; |
what seems to be the most popular option is a double render on the server, the first one to create the state and the second to render the code.
|
@gabrielbull Could you clarify usage with Redux - use your comment above or the README 'with Redux` section? |
Hi
this is awesome project, but it definitely needs redux support.
Is this on the road-map?
The text was updated successfully, but these errors were encountered: