-
Notifications
You must be signed in to change notification settings - Fork 38
Click not handled after you return to a page #18
Comments
Can you get me some more details so I can reproduce?
If the DOM tree isn't changing, then the event listener shouldn't be lost. |
Ah, that's good to know - perhaps I'm inadvertently doing something a bit strange then! Let me see if I can reduce it down to a test case that I can share, then. I'll post an update here soon. |
Any updates on what the issue was? |
Sorry for the delay, Larry. Just trying to build a little test case now. Hope to post it here tonight or tomorrow. |
OK, here is a quick test case: https://github.com/poshaughnessy/react-mini-router-test NB. I used a standalone version of your library, that I made using
Instructions / steps to reproduce the problem (also included in the README):
Tested in Chrome v40 and Firefox v35. Hope this helps! |
@poshaughnessy Thanks! That will be extremely helpful in debugging. I've attached this issue to the 1.1 milestone, so expect to see it resolved this month. |
There is actually a very simple workaround, at least for us it worked well - wrap the component produced by the route function (that is different for each route) into a render: function() {
return this.renderCurrentRoute();
}, do this render: function() {
return (<div>{this.renderCurrentRoute()}</div>);
}, in your root component with the |
I ran into this issue today. @jakubholynet 's solution worked. |
Still running into this, @jakubholynet's solution helped me out! Thank you. @larrymyers it'd be awesome if this was noted on the README if the code fix is a little ways off! |
Thanks for this library! It's working well for me, except...
handleClick
is assigned as an event listener to the DOM node incomponentDidMount
. However, if you navigate to another 'page' in your Single Page App, and then go back to your previous 'page',componentDidMount
doesn't fire again for that first page, and the original event listener is lost? (That's what happens for me anyway - testing with Chrome v39). This means that when you now click another link on that first page, it won't be caught - it will result in a full page request.How about also adding the event listener in componentDidUpdate? I tried it and it fixed the problem for me. (I was worried it might keep adding more and more event listeners, but it looks like addEventListener shouldn't allow duplicates*).
If this sounds good, it's just a case of adding:
(I could issue a pull request if you like).
*Or an extra cautious way could be to do
removeEventListener
just before theaddEventListener
?The text was updated successfully, but these errors were encountered: