YahooArchive / fluxible-router

MOVED TO FLUXIBLE REPO
104 stars 26 forks source link

[Question] How to pass query string to a NavLink and a navigateAction #74

Open bchelli opened 9 years ago

bchelli commented 9 years ago

Hi Guys,

First of all, awesome job here, this really helped me kick start my React project.

I have an issue though, I would like to be able to pass query string parameters to:

    <NavLink routeName="login" queryParams={{redirect:'/some/other/url'}}>Login</NavLink>
    context.executeAction(navigateAction, {
        type:   'click',
        url:    '/login/url',
        query: {
            redirect:'/some/other/url'
        }
    }, done);

I guess the way I'm trying to do this is not the fluxible way, so could you point me in the right direction.

Should I use the navParams to pass the query string values to the route and therefore define optional query string parameters in the path of the route (as asked in the issue #42)?

var routes = {
    login: {
        method:  'GET',
        path:    '/login/url?redirect=:redirect',
        handler: LoginPageHandler
    }
};

Thanks, Ben

geekyme commented 9 years ago

you would have to pass the query params in the href eg. href=/login/url?redirect=%20/home

bchelli commented 9 years ago

Hi @geekyme,

First of all, thanks for the help.

Getting back to the issue, I think I have omitted an important point in my previous message:

I would like to avoid as much as possible the utilization of href and more generally any type of hard coded URL. This should prevent me from having to go through the entire application's source-code and check if / how to update URLs when a change occurs in the pattern of one URL.

Let me know if this makes sense.

Thanks, Ben