Skip to content

react-router: Mismatch, wrong type for Route? #4267

Closed

Description

@tugend

Hi. I am trying to use React-Router with React 0.13.2.
The following is valid typescript, compiles and performs as expected - but only if i widden routes to 'any'.

var Route = React.createFactory(Router.Route)
...
var routes = Route({path: "/", handler: MyReactComponent}, ...)
Router.run(<any>routes, Router.HistoryLocation, handler)

If I remove <any> I get, "Argument of type 'ReactElement<RouteProp>' is not assignable to parameter of type 'Route'.

I can't figure out whether I am using the Router in the wrong way, or the migration to React 0.13 clash with the type declarations. I would be much obliged if you could help me solve the question.

-- Cheers

Activity

  1. changed the title [-]Mismatch, wrong type for Route?[/-] [+]react-router: Mismatch, wrong type for Route?[/+] on May 5, 2015
  2. tugend commented on May 7, 2015

    @tugend
    Author

    Will do, thank you.

  3. mrk21 commented on May 10, 2015

    @mrk21
    Contributor

    Hi @tugend,

    The reason this issue was occurred is that Router.run() does not support to call with ReactElement created by React.createFactory().

    Therefore, I fixed it.

    If the following pull request is merged, you will be able to remove <any> from the above code.

  4. duncanmak commented on Jun 6, 2015

    @duncanmak
    Contributor

    @tugend You might want to try #4173 and see if that works better or not.

  5. tugend commented on Jun 6, 2015

    @tugend
    Author

    Thank you for the suggestion, but @mrk21 fixed the problem (always the champ!). =)

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