Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

URL query compatibility with react-router routes and location #638

Closed

Description

@peterlazzarino

I've been using asp prerendering for an application that uses the query string to for fetching data that I want rendered on the server. I noticed while following the react example that the query string was being encoded incorrectly but only on the server side when the location is created in createServerRenderer and then passed into react router.

I traced it to react-router and creatememoryhistory expecting the query field on the location object to be a key value pair object and not a string like it is in the createserverrenderer params. Since you are using url.parse and there is an option to pass true for it be an object, can this be exposed as a parameter somewhere? Using this allows me to use the query on the server and client. I'm not sure of the implications of switching this to true and then submitting a PR.

Activity

  1. peterlazzarino commented on Feb 2, 2017

    @peterlazzarino
    ContributorAuthor

    Also wanted to mention that when using createserverrenderer with react-router the string encoding of the querystring caused the issue inside of creatememoryhistory when it called the defaultStringifyQuery method of useQueries which calls query-string.stringify which is the method that expects the query object.

    Hope this all makes sense haha

  2. SteveSandersonMS commented on Feb 3, 2017

    @SteveSandersonMS
    Member

    Thanks for the suggestion! I've updated aspnet-prerendering to version 2.0.3, which does parse the querystring in the way you've requested. This should make the server-side and client-side routing behaviours consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions