agamennon / redux-tiny-router Goto Github PK
View Code? Open in Web Editor NEWA Router made for Redux and made for universal apps! stop using the router as a controller... its just state!
A Router made for Redux and made for universal apps! stop using the router as a controller... its just state!
Due to a hard dependency to React 0.13, this library does not work with React 0.14 because the rendering API of react has changed.
package.json lists react ^0.13.3 as a dependency. It seems more appropriate to be a peer dependency, in any case.
For example I like the way flask does it and forces a type:
/project/edit/<int:project_id>/
Additionally I'd say then you need a way to generate a URL as well...
I'd love it if there was a global way to add the trailing slash or not as well.
But this currently looks very clean and reduxy ;-) React Router is very overbearing and I'm not sure they have got everything right with their recent 1.0 API changes. Well played.
Getting UNIVERSAL and CLIENT undefined.
Hey
Looks like when I'm combining reducers the initial state isn't set somehow.
I can see the state as
Object {counter: Object}
so router is missing.
My reducer function looks like this:
import { combineReducers } from 'redux';
import counter from './counter';
import { tinyReducer } from 'redux-tiny-router';
const rootReducer = combineReducers({
tinyReducer,
counter,
});
export default rootReducer;
Am I missing something?
When using the OPTION2 initialization, described in the README.md, getting this JavaScript error:
Uncaught ReferenceError: __UNIVERSAL__ is not defined
Setting window.__UNIVERSAL__ = false;
before initialization fixes the issue.
The error is happening in reduxTinyRouter.js
at window.__UNIVERSAL__ = __UNIVERSAL__ || false;
Hey,
your library sounds interesting!
I have one question though which apparently is quite unclear how to solve it with redux + router.
So let's say I'm on a page where I have a form. I fill up the form and I submit it. After the submit, if successful, I want to redirect to another page otherwise show an error message on the form page itself.
This is a quite common use case but I haven't figure it out how to properly redirect.
The flow looks like this:
Before the last step I should know if I need to redirect or re-render and show an error message. But how would you do it? The reducer simply returns the state and the component needs to check for something to make a decision (e.g.: redirect or not). I could set into the state something like shouldRedirect: true
so the component knows it has to redirect but this is not nice.
Ideally I want to say: given that action I want to transition to somewhere.
What are your thoughts? Thanks!
It would be great to be able to use setRoutes from within the component (constructor probably). I could then do this:
_getRoutes() {
return {
'/': <SomeComponent />,
'/users/*': <SomeOtherComponent>,
}
}
constructor() {
super();
utils.setRoutes(Object.keys(this._getRoutes()));
}
And then later something like const component = this._getRoutes(this.props.router.src)
to choose the component.
However, it seems i can only do it externally to the class. Is this fixable?
I find it weird. Is there a good reason we have this?
By the way, thanks for your good work! ๐
Aside from the great set of edge-cases it handles, using history in r-t-r would allow the use of extensions such as redux-history-transitions.
There is an error that prevents rendering using Firefox 42 on Windows 7:
TypeError: setting a property that has only a getter
The error occurs on line 28
of enhancer/enhancer.js
:
Object.assign(reducer,tinyReducer,reducer);
I can fix the error by changing that line to:
Object.assign(reducer,tinyReducer);
Between react-router (which looks like overkill and not well fitted for redux) and nothing (https://gist.github.com/HenrikJoreteg/530c1da6a5e0ff9bd9ad) this router looks very good. I may have missed it but I don't see any hello world example or any pointers. Could you please provide something, even if it is only a short description?
Hello @Agamennon
first I'd like to thank you for this library, love the philosophy. I was going to write something similar myself when I stubbled uppon your code :)
That said, as I am starting a new project in my company, I am a little worried to see that pull request from months ago are still to be merged.
So I guess my question is, are you still maintaining this project ?
I'll be glad to help if needed.
Hey! Soooooo in to this as a routing solution. Thank you for making it :D.
I'm going to dig through the source a little, but wanted to see if you had plans/thoughts on reading the state from a hash fragment as an optional alternative to reading the standard path.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.