Comments (7)
// (optional)
history:
{
// (optional)
// `history` options (like `basename`)
options: {}
// (optional)
// Custom `history` wrapper, like `syncHistoryWithStore` from `react-router-redux`
wrap: (history, { store }) => history
}
from react-pages.
If someone wants syncHistoryWithStore
then they could try to implement that.
Consider client-side:
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/redux/client/client.js#L44
There history
is created and could be wrapped with syncHistoryWithStore
immediately.
But the store
is created right after and it currently takes an already created history
as an argument.
The store creation function doesn't use the history
though so it could be replaced with something like:
const history_holder = {}
function get_history() { return history_holder.history }
const store = create_store(..., get_history, ...)
const history = syncHistoryWithStore(create_history(...))
history_holder.history = history
And also history
would get replaced with get_history()
in the two middlewares:
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/redux/middleware/history%20middleware.js
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/redux/middleware/preloading%20middleware.js
So, wrapping with syncHistoryWithStore
could be done (on the client side).
As for the server side, history
is created here:
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/page-server/render.js#L47
Again, the same situation: history
is created before the store
, and the store
creation function is passed the history
parameter which it doesn't use immediately so it could be analogously replaced with the same get_history()
trick.
After the await redux_initialize
call the store
is available as parameters.store
.
So it seems that the wrapping can be done both on client and server.
So if one forks this project, performs the changes, tests it both with javascript enabled and javascript disabled, and in case that works as intended I would think on a new configuration parameter like history.wrap
.
I myself am not using react-router-redux
, using @withRouter
instead.
from react-pages.
I was thinking about making this change.
Have you started already?
from react-pages.
Not yet, much appreciated!
from react-pages.
Released [email protected]
.
Didn't check it so you're gonna be the beta-tester.
from react-pages.
However one more thing is in order for react-router-redux
to work, need to add
import {routerMiddleware} from 'react-router-redux';
const middleware = [
routerMiddleware(history),
];
applyMiddleware(...middleware)(createStore)(reducers, initialState);
I am not sure in react-isomorphic-render.js
reduxMiddleware: () => [routerMiddleware(history)],
how I can get history
? Thanks very much in advance.
from react-pages.
How do they pass routerMiddleware(history)
to createStore
when history itself needs store
to be created in the first place as you described in your first post
from react-pages.
Related Issues (20)
- Access store outside React scope HOT 4
- Adding json-ld script tags (dynamic) in SSR pages HOT 1
- Can't add custom handler for `@@react-isomorphic-render/goto` event HOT 4
- Error running npm install HOT 1
- The test is failed. (npm install) HOT 1
- usage directions fail at npm install babel-node HOT 1
- SSR middlewares HOT 2
- react-router problem HOT 7
- Http utility in Server Side HOT 11
- how can i run this site? HOT 8
- How modify @preload {client: true} configuration HOT 5
- How to capture an event type HOT 2
- Crash in long running production process (v 2.0.13) HOT 2
- Module not found: Error: Can't resolve './aboutPageReducer' in ...... HOT 1
- Error instantiating router HOT 5
- No way to detect authentication before using http client HOT 2
- [SSR] Access to the request headers HOT 4
- Enable configuration entry for HTTP `on_before_send` HOT 8
- Invalid Content-Type for get and multipart requests HOT 3
- Moving from isomorphic to website causes render service error HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-pages.