-
Notifications
You must be signed in to change notification settings - Fork 111
5.0.0 #12
5.0.0 #12
Conversation
src/link.js
Outdated
| }; | ||
|
|
||
| const clickedWithModifier = e => | ||
| e.button === LEFT_MOUSE_BUTTON && |
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 don't think you want to check for LEFT_MOUSE_BUTTON here. (I haven't tested this, so could be wrong).
This behavior should happen if you're clicking a link by pressing enter on the keyboard as well.
We'll also want to check for right clicks and not trigger any behavior on them. This module includes some logic that handles this. Don't know if we want to use the whole thing or not because it does some other stuff too: https://github.com/lukekarrys/local-links/blob/master/local-links.js#L26-L28
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.
Totally right, not sure what I was thinking there 😆
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.
Latest commit should do the trick! Tested with the enter key: uses pushState without modifiers, default if using modifiers 👍 Also checking for the target prop
- Use the history query enhancer for query strings - router.current now lives on router - much better link - store enhancer no longer owns middleware
6189992 to
970e68d
Compare
src/initial-state-for-ssr.js
Outdated
| import createMatcher from './create-matcher'; | ||
|
|
||
| export default ({ url, query, routes, history }) => | ||
| Object.assign({}, |
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 versions of IE support Object.assign, and it doesn't appear to be included in es5-shim either. So we'll either need to call it out that you need an assign polyfill, don't support IE (not really an option for us), or pull in _.assign. I vote for the last option.
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.
Ew! Definitely the lodash one.
|
A couple of questions, but the rest LGTM! No need for re-review once those are addressed. |
| .that.contains('/home/messages/a-team'); | ||
| expect(payload).to.have.property('query') | ||
| .that.deep.equals({ test: 'ing' }); | ||
| done(); |
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.
If the expect statements above fail, the test will timeout. This is because an Error is thrown, but it is thrown outside the stack frame of the it block (its asynchronous). There are a couple of ways you can resolve this:
- Wrap all async
expectstatements in atry...catchblock, and pass any caught errors todone. In other projects, I've done this with a helper function that looks likecaptureErrors(done, () => { /* expect statements here */ });. This function callsdonewith a thrown error if it occurs, and otherwise calls done with no args. - Return
Promise.resolve().then(() => { /* expect statements here */ });in theitcallback. If the promise rejects, the test will fail with the rejection reason. - Make the test only fake-synchronous. This isn't always possible or desirable, because often library code is asynchronous and outside of your control.
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.
const isNotLeftClick = e => e.button !== LEFT_MOUSE_BUTTON;e.button is undefined in enzyme simulated clicks. This means that we never reach the real <Link> behavior. Here's the fix:
const isNotLeftClick = e => e.button && e.button !== LEFT_MOUSE_BUTTON;😆
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.
(the expects should still be wrapped, but that can be done in a separate PR)
…me simulated clicks)
This should end our API churn.
<Link>now respects modifier keys!<Link>now accepts either a string or an object like so:<Link>comes in two flavors now:<Link>(old behavior) and<PersistentQueryLink>(persists the previous query string unless thehrefprop provides one). Since you'll probably just use one or the other, this is a nice pattern:historylistener now lives in the store enhancer. The middleware no longer lives in the enhancer and must be used separately due to middleware order issues.redux-loop.routerstate tree like it always should've (no morerouter.current). You can still access the previous route onrouter.previous.Fragmentcomponent that shows or hides children based on active routes (and even conditions of those active routes).provideRouteradds the router context to a top-level component. This means that<Link>no longer requires you to pass indispatchandhistory(THANK GOD).