-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Issue on "/" paths #1
Comments
That's strange. |
|
The thing is that it's kinda solved when you render the component like this
That way it only console.log 'BBB' or 'AAA' accodingly the route. |
Can you make a codesandbox that replicates this behavior for me? I'm having a hard time replicating it on my end. |
Hi Tanner, here the example https://codesandbox.io/s/53jjln4654 You see that both console log executes, even when i enter to inovice. Only 1 console should execute. Regards! |
Nice. This is more clear. Thanks for the info. I'm still trying to figure out how or why this happens. Would be up to helping me investigate? |
I feel like its some of this logic here: https://github.com/tannerlinsley/react-location/blob/master/src/index.js#L213-L220 |
Tanner, first of all I want to tell you that Diego and I are friends and we are talking about this topic since he discovered it. My theory is that the child is rendered first, therefore the javascript code is executed, and then when rendering the parent, that child is hidden because it does not match the path, but the javascript has already been executed. On the other hand, when the child is a callback, this does not happen because the render trigger of the child occurs by the parent itself. In conclusion, the routing works well, but the javascript of each Match child is executed regardless of whether match or no match |
That shouldn't be the case, since we are inspecting the match child props
before it is rendered.
…On Thu, Jan 31, 2019 at 10:22 AM Nicolas Bocassi ***@***.***> wrote:
Tanner, first of all I want to tell you that Diego and I are friends and
we are talking about this topic since he discovered it.
My theory is that the child is rendered first, therefore the javascript
code is executed, and then when rendering the parent, that child is hidden
because it does not match the path, but the javascript has already been
executed. On the other hand, when the child is a callback, this does not
happen because the render trigger of the child occurs by the parent itself.
In conclusion, the routing works well, but the javascript of each Match
child is executed regardless of whether match or no match
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFUmCRbsKlO1ofW6fEiiR5VWAB2sgDsUks5vIyZdgaJpZM4aLMpu>
.
|
So, you're trying to say that the console.log should not be executed unless it meets the condition of match? I'm not sure how the interpreter works, but I get the feeling that it's running before the rendering.
When replacing the child by callback the problem disappears, which makes me think that it is not a match problem.
|
I think you're right as well. I was merely pointing out that it's not designed to render the content unless it matches. That definitely narrows the bug type we're looking for. |
Yes, I did not mean to render, that word came out but I wanted to refer to the assembly of the component regardless of whether it is rendered or not. What I'm not 100% sure, is that the execution of those console.log is correct, it would be ideal not. I hope you can find the explanation of what happens :) |
Great Job Tanner, this version seems to work perfect! Also the basepath works well. Thanks! |
Thanks! |
Hi Tanner i figured it out that when we have the component like this
Both console.log execute is like we're missing some exact param or something else.
The text was updated successfully, but these errors were encountered: