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

Router::generate(name string, params object) - generate paths by name #22

Closed
wants to merge 4 commits into from
Closed

Conversation

sanches89
Copy link
Contributor

Implement Router::generate(name string, params object) to use in the Link component of React Starter Kit

@koistya
Copy link
Member

koistya commented Mar 12, 2016

I think supporting optional name parameter in each route is a great idea. But not sure if "generate URL" functionality should be a part of the core routing library. What do you think?

@koistya
Copy link
Member

koistya commented Mar 25, 2016

@sanchesic89 FYI, I just have cleaned up the project, removed all the extra dependencies not related to the router itself. What do you think about having "generate URL" functionality in some external class/utility? For example, you can have a list of routes as a JavaScript array:

// ./routes/index.js
export default [
  { name: 'home', path: '/', action: ... },
  { name: 'product', path: '/products/:id': action: ... }
];

That can be used by both the router and a "link builder", for example:

import router from 'universal-router';
import routes from './routes';

router(routes, /* context */);
// Link/URL builder
import routes from '../routes';

function href(routeName, routeParams) { ... }

export default href;

That can be used as href('product', { id: 123 }).

@tommiv
Copy link

tommiv commented Aug 9, 2016

Any news on this, guys? It's a highly required feature.

@langpavel
Copy link
Collaborator

@koistya Hi, I'm think this is especially useful and really often requested feature. Can you consider merge? I must admit that I didn't reviewed code carefully but I'm sure @sanches89 using this in production.

@sanches89 Can you give us feedback, do you using this in project?

@sanches89
Copy link
Contributor Author

Hi everyone, the project change so much that I need to rebuild all the implementation. So I made a new pull request #74

@gustavohenke
Copy link

So close this one @sanches89 :)

@sanches89 sanches89 closed this Dec 27, 2016
@frenzzy frenzzy mentioned this pull request Mar 27, 2017
20 tasks
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

Successfully merging this pull request may close these issues.

5 participants