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

Couple of <Link> questions #2080

Closed
dan-gamble opened this issue Sep 25, 2015 · 10 comments
Closed

Couple of <Link> questions #2080

dan-gamble opened this issue Sep 25, 2015 · 10 comments

Comments

@dan-gamble
Copy link

How would i use a <Link> in an component that doesn't seem to be the wrapping <App /> comoponent? I get this error:

A <Link> should not be rendered outside the context of history; some features including real hrefs, active styling, and navigation will not function correctly

An example of when i would use this is like: https://github.com/rackt/react-router/blob/master/docs/Introduction.md#adding-more-ui and i would put a <Link> inside of the <Message> component.

Also are you able to <Link toName='nameOfRoute'> to link to a <Route> regardless of it's path?

@knowbody
Copy link
Contributor

which version of React Router are you using? the 1.0.0-rc1 is not using named routes anymore so you would need to specify the path in your <Link to='/YOUR_PATH'>

@dan-gamble
Copy link
Author

I'm using: https://github.com/thereactivestack/meteor-react-router/ which seems to require: 'react-router': '1.0.0-rc1',

Is there a reason named routes were removed? I ask because i use Django mainly at the moment which has a function `{% url 'namespace:name' %} which allows me to change paths without breaking my app. Granted paths are rarely changed it's still a nice little feature.

So is the only way to link to Routes via a path?

@knowbody
Copy link
Contributor

Have a look at #1840 there is a discussion about maybe bringing them back.

And yes only via path.

@dan-gamble
Copy link
Author

That answers the name question at least thank you :) I do like the Named Component method of doing that though and i could go down that route!

Just a case of finding out how to use <Link> in individual components that don't seem to have access to history

@knowbody
Copy link
Contributor

the other question - putting <Link> in the Message component works fine for me

@dan-gamble
Copy link
Author

I thought that might break it as it looks similar to the code i have at home. When i get home today i'll post my code example and see if that makes more sense, thanks for your help :)

@knowbody
Copy link
Contributor

👍 let me know, closing for now.

@dan-gamble
Copy link
Author

Hey, just uploaded my repo :) The Component i was having trouble with was this one: https://github.com/DanGamble89/meteor-webpack-react-kickstart/blob/master/react/index.jsx#L26

That line throws me the error,

@knowbody
Copy link
Contributor

knowbody commented Oct 4, 2015

@DanGamble89 are you still having issue with it? sorry I forgot to get back to you.

@dan-gamble
Copy link
Author

@knowbody I haven't tried it again since i've uploaded it but i'm pretty sure that repo has the bug. I'll be trying it again this week so i'll post back in here with what i find again :)

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants