Skip to content
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

navigation and enhancers #21

Open
quarkcore opened this issue Apr 26, 2018 · 4 comments
Open

navigation and enhancers #21

quarkcore opened this issue Apr 26, 2018 · 4 comments

Comments

@quarkcore
Copy link
Contributor

@HenrikJoreteg hi, which kind of navigation u are unsing? i try to add react-router with react-router-redux but have some trouble.

ther for i need to add some middleware but applayMiddleware() of your package does not working as expected.

import createStore from '...';
import { applyMiddleware } from 'redux-bundler';

import { testEnhancer } from '...';

//used like that console.log in testEnhancer never logs
store = createStore({}, applyMiddleware(testEnhancer()));

any idea?

@quarkcore
Copy link
Contributor Author

Works like that!
strange behavoir anyhow. why cant i pass an empty object as initial state?

import createStore from '...';
import { applyMiddleware } from 'redux-bundler';

import { testEnhancer } from '...';

store = createStore(applyMiddleware(testEnhancer()));

@HenrikJoreteg
Copy link
Owner

@quarkcore you should read my book 😀 there's a whole chapter on routing. Anway... this is how I do routing:

URL bundle + Route bundle:
https://github.com/HenrikJoreteg/redux-bundler-example/blob/master/src/bundles/routes.js

Then this one helper at the root of your component tree: https://github.com/HenrikJoreteg/redux-bundler-example/blob/master/src/components/layout.js#L17 this makes it so you don't need any special "link" tags or anything just render regular <a> tags and as the clicks bubble up this helper sorts out whether to treat it as internal navigation or not.

Then I use selectRoute to grab the current component based on the routes, and assign it to <Page/> and render it: https://github.com/HenrikJoreteg/redux-bundler-example/blob/master/src/components/layout.js#L13

Anywhere you need route params you can just use selectRouteParams to get an object of named route parameters or selectPathname to get current pathname, etc. The URL bundle has tons of selectors.

@olizilla
Copy link
Contributor

We just hit the same issue. We have to do hash-based routing (our app may not be mounted at the root of the domain) and are trying to figure out how best to get it working with redux-bundler. We could sprinkle hash based routes all over the code, but we thought we'd try mixing it with react-router first to see if that could work. Neither approach seems ideal.

@olizilla
Copy link
Contributor

We got hash based routing working the redux-bundler way by parameterising the routeInfo selector in create-route-bundle... #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants