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

Need some help moving from ko-contrib-router to knockout-contrib-router 2 #97

Closed
mcgoncalves opened this issue Jun 27, 2018 · 3 comments

Comments

@mcgoncalves
Copy link

mcgoncalves commented Jun 27, 2018

Hi Casey,

We’ve recently started migrating from ko-component-router to knockout-contrib-router and there are some things we noticed and wanted to know if they are bugs or behavior misunderstandings from our side.

I’ve created a codesandbox project where every single issue reported below can be reproduced. Here’s the demo link: https://p938k153rj.codesandbox.io/user
You can check the code at https://codesandbox.io/s/p938k153rj

Difficulties with the Path Binding (:heavy_check_mark: - @caseyWebb)

From the second router level below, we are no longer able to use the path bind ./, to access child routes, we must add the hardcoded path instead, or work around it using the canonicalPath.
This is indicated in the green/red text: https://p938k153rj.codesandbox.io/user/new/details
The path binding seems to work well for the first level, but not for the second and below.

image

Children component re-renders when clicking on href for the same route

From the second router level below, when we hit the same navigation item it re-renders the child component. This doesn’t happen at the top level.

In order to test this, click on the ‘Users’ link multiple times. You will notice that the first level “rendered at X ms message” is always the same. This is the expected behavior for me: clicking on the same link doesn’t trigger a re-rendering. It also works fine for the second level ‘New’ and ‘Edit’ navigation items.

But if you click on the ‘Details’ or ‘Contact’ the child component gets re-rendered, every time you click them.

Here is a sample video of this behavior: https://www.screencast.com/t/xmgbuWLKWav

Also, I’ve noticed that the first time I click on the ‘Users’ link the browser navigates to ‘/user’. The second time I click on it, the browser navigates to ‘/user/’.

Let me just say thank you for the router. The newer version is way better and a lot cleaner.

@caseyWebb
Copy link
Contributor

Hey, thanks so much for the detailed report and test cases, really really going to be helpful. I think this is just the repro case I needed for an issue reported by someone else for the path binding.

I'll hopefully be able to dig into this tomorrow or Friday. I suspect that some of the changes I've been experimenting with locally may have the latent effect of resolving the path binding issue.

@mcgoncalves
Copy link
Author

I'm glad this helps. Thanks for the quick answer.

@mcgoncalves
Copy link
Author

Hey,

I've updated to rc.2 from my previous demo and tested the changes done in this last versions.
The problem with the 'Difficulties with the Path Binding' appears to be solved.

The only problem, from this issue, that isn't solved yet is 'Children component re-renders when clicking on href for the same route'.

I've also tested the /*option to add active-path class for any of the child routes opened and it works just as expected, it's nice to have this.

You can check the updated demo here: https://codesandbox.io/s/j25n5n44qy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants