-
Notifications
You must be signed in to change notification settings - Fork 163
React Router v4 support #201
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on official example. children
function is called even if current URL doesn't match. It's called with an object that contains a match
and a history
properties but match
will be null if there was no match. Thus it becomes possible to find out if activeClassName
and/or activeStyle
should be applied to the container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is...wonky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, sorry it wasn't a criticism of the code, just the RR api choice
JesseObrien
commented
Mar 18, 2017
Is there any more activity on this? I'd like to make use of this so I don't need to hack things into my current v4 project.
Apparently, it now uses react-router-dom package, which is designed to be used within browser environments
Just updated this PR to use the latest version of React Router (v4 is now officially released, hooray 🎉)
MHarris021
commented
Mar 23, 2017
Can we get this pulled soon please. I'm writing an application for our support team that requires react router v4 and this issue is delaying development.
@react-bootstrap/collaborators anyone use RRv4 who can review this? neither @taion or I use it.
Speaking of which does anyone want to maintain this a bit more actively?
@taion
I just tested out the LinkContainer code and it fails without supplying the context on creation. Any guide or comments on how to it correctly?
this is the block that throws the error:
static contextTypes = {
router: PropTypes.shape({
push: PropTypes.func.isRequired,
replace: PropTypes.func.isRequired,
createHref: PropTypes.func.isRequired,
}).isRequired,
};
this is used by the render method when rendering the <Route>
component
@MHarris021 seems you're using not the latest commit because contextTypes
prop doesn't match - it should be like this
MHarris021
commented
Mar 23, 2017
Thank you. I got it working by making that exact change in the source code I copied from you. I also had to change the call this.context.router.createHref(...
to this.context.router.history.createHref(...
It is now rendering properly and my children wrapped in <LinkContainer>
are properly having their hrefs changed correctly.
@v12 thank you for putting this together
techrah
commented
Mar 30, 2017
@jquense I just tested @v12's changes by wrapping a NavItem
with a LinkContainer
and it works! I tested this by installing the current version with npm install react-router-bootstrap
, parsing LinkContainer.js
and IndexLinkContainer.js
through babel and replacing those files in lib/
. I did not need to make any additional changes regarding createHref
as @MHarris021 mentioned.
Based on the manual tests done so far and that the CI tests have passed, is this enough to accept and merge this PR? If not, what else can we do to help? As the community moves to RRv4, we're really going to need this asap.
Big thanks to everyone for all the hard work!
techrah
commented
Apr 3, 2017
yarrumretep
commented
Apr 4, 2017
+1 for this PR
To reiterate, where we stand right now is that none of the current active maintainers use RRv4. The code looks fine as far as we can tell, but we can't commit to maintaining this.
We'd be happy to add one or more persons as a maintainer, but we don't really have a path forward here without that.
jjinux
commented
Apr 4, 2017
Hey, @taion, I'm from Udemy. I'm in the process of moving us to RRv4. I don't really know the react-router-bootstrap codebase, and so I don't know how good the patch is. However, if you're looking for people who plan on using this in production, I'm one of them.
The code here is all there is. There's nothing to this library other than <LinkContainer>
. But someone has to be on the hook for e.g. fixing bugs as they come up, and it can't be any of the existing maintainers.
jjinux
commented
Apr 4, 2017
I can do it. Or, we can have @zloiroc (the guy who did core-js) do it since he also works for Udemy. What about @v12--he was the one who submitted the patch?
I assume we should start a new major version number, and there should be some documentation about which version to use based on which version of react-router you're using. New bugs for the RRv3 version can be made against a release branch.
zloirock
commented
Apr 4, 2017
thanks. either way, ideally we'd like to have a couple of people who can maintain this just in case something comes up, since the current maintainers aren't going to be able to do so
@taion sure, I can do that. RRv4 is used in a few huge apps we have developed, so react-router-bootstrap is definitely something I'm going to rely on for a long time. But I also do agree that there should be at least a couple of people in case I'm not available. Moreover, it's always good to have another fresh pair of eyes 😉
Great! Can we get a +1 here from one of you on this code?
techrah
commented
Apr 6, 2017
I have just embarked on a project that will use RRv4 but this is new to me so I am unsure how much help I will be able to provide at the moment but am willing to help out as much as I can. So far, this fix has been working for me but I haven't really put it through its paces yet.
Is there still no volunteers to review the PR? 😃
Looking at the activity in this thread as well as in the related issue, would anyone want to have a look at the code? It may look like there are a lot of changes based on changed lines counter, however, most of the changes are related to tests in order to make them compatible with RRv4. Just in case, there is also visual-test
script, which can be run to see the library in action, and helps to see that there are no differences between standard React Bootstrap components and them being wrapped with react-router-bootstrap
. The latter ones also behave as usual RRv4 links.
Let me know if there is anything else I can do to speed up merge of this PR because, from what I see, it's one of the things that we need as RRv4 becomes more and more frequently used by community. 😉
@jjinux
jjinux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I certainly don't understand every detail, but LGTM.
You need to:
-
Create a branch for the existing code so that bug fixes and new releases can continue to be made for the code that works for the pre-RRv4 version of the code.
-
Update the README to say that people using versions of RR earlier than v4 should use ealier versions of this library, whereas people using RRv4 should use such and such a version or later.
-
Create a new major version number and do a release.
@jjinux
jjinux
Apr 10, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give this a default? Same question for anything else that's not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it's worth to add default values for exact
and strict
props that relate to how React Router detects if route is active. However, I don't think it's worth to add default values for other non-required props just because it does not add any value and those may not be defined, so there is no need to pass them down to underlying component.
Obviously, I can set undefined
for them in defaultProps
but does it make any sense? Seems to just increase amount of code since these props are undefined anyway.
@jjinux
jjinux
Apr 10, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change something that you need to document in a changelog so that people know that they need to make it to their own code?
@jjinux
jjinux
Apr 10, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and remember to update the CHANGELOG.md just in general ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not necessary change - I updated URLs just for the sake of clarity as having absolute path looks more clear to me (you definitely know that it points to /home
and not some /something/home
).
Yes, sure, I'll definitely update changelog 👍
jjinux
commented
Apr 10, 2017
Is there any chance we can get a beta release of this published to npm to facilitate testing?
jjinux
commented
Apr 10, 2017
It's working for me:
@jjinux huge thanks for your review!
Regarding major version bump, I'm not sure if this is applicable as react-router-bootstrap is still in unstable stage and, according to SemVer spec (here), API can change unless version is >=1.0.0
Although, if @jquense and @taion agree, then we can go into public release stage by publishing this as 1.0.0-beta.0
first and, after some time, if there are no issues, we can proceed with 1.0.0 release?
RB projects follow the general node package convention of treating minor versions <1.0.0 as "major" bumps and patch bumps as patch and minor. you can jump to 1.0.0 if you want, or just bump the minor spot.
jjinux
commented
Apr 11, 2017
I would just release a 0.24.0, but that's just my opinion based on limited knowledge.
MiLk
commented
Apr 15, 2017
Can we also have the release published on npm?
https://www.npmjs.com/package/react-router-bootstrap is still showing 0.23.1
Thank you.
@MiLk yes, sure, I've already asked publishers to release it on npm because I don't have access to this package there
oof, there was a publish script here that handles some of the pub tasks. going to need a bit of time to unwind this – probably not until monday
@taion no worries! Have a great weekend 😉
parse
commented
Apr 19, 2017
Did the 0.24.1 release drop support for react-router v3?
correct – the APIs are totally different so it's impossible to support both.
v0.23.x will continue to work fine with RRv2 and RRv3, though, and will continue to work indefinitely.
@v12 given that LinkContainer.js
actually imports from react-router-dom, you should add an explicit peer dependency there
parse
commented
Apr 19, 2017
Gotcha, thanks!
I'm going to be stuck at v0.23.x for a couple of months before I can make the switch. Any plans to release a patch for 0.23.x to address the React proptype deprecation warnings?
feel free to submit a PR, or we might get to it eventually. we'll continue to cut releases off v0.23.x. for many classes of applications RRv2 and RRv3 remain a better fit than RRv4, so the old releases aren't deprecated or anything.
parse
commented
Apr 19, 2017
@taion I made an attempt here: https://github.com/react-bootstrap/react-router-bootstrap/pull/207/files
released v0.23.2
note that if you're currently using RRv2 or RRv3, found is probably a better upgrade path than RRv4, and support for this sort of thing is available mostly out-of-the-box there without an extra integration
parse
commented
Apr 19, 2017
Thanks @taion ! Impressed by the speed! :)
In react-bootstrap#201, the switch to `react-router-dom` was made but the webpack config was not updated. Therefore, the current UMD bundles include `react-router-dom` and depend on `react-router`.
Uh oh!
There was an error while loading. Please reload this page.
So, React Router is now in the beta stage and no major changes are expected to its API.
Here is my attempt to implement RR v4 support 😄
Addresses #186