Closed fadi-mimi closed 2 years ago
Hi @fadi-mimi, thanks for the issue. If you have a moment to put together a PR with a solution that would be greatly appreciated 🙏
I made a PR to reproduce the issue. The test was already there and skipped. There was the problem with the breakpoint which was mocked before the server rendering. But this is not the case in reality since these are just defined on the client. So I did the mocking after the server rendering and the error occurs as expected. I also put the snapshots there so you can see the difference between server and client markup. React treats this as a hydration error.
This is quite a huge change architectural wise and I don't have the feeling that I'm the guy to decide this.
I made a PR to reproduce the issue. The test was already there and skipped. There was the problem with the breakpoint which was mocked before the server rendering. But this is not the case in reality since these are just defined on the client. So I did the mocking after the server rendering and the error occurs as expected. I also put the snapshots there so you can see the difference between server and client markup. React treats this as a hydration error.
This is quite a huge change architectural wise and I don't have the feeling that I'm the guy to decide this.
Hey @fadi-mimi hope you'r doing well. any news from your PR. I hardly need your PR if it is solved the miss-match issue.
Hey all, sorry for the delay. Things are very busy over here right now. We'll happily accept PRs to fix issues but unfortunately, short of that, this issue will have to wait.
Hey @fadi-mimi, the Same issue for me, do we have to wait long?
Hey all, sorry for the delay. Things are very busy over here right now. We'll happily accept PRs to fix issues but unfortunately, short of that, this issue will have to wait.
thanks for your respond quickly. to be honest i am going to use common way css display property if it is going to take more than one week. what is your idea?
I think <Media />
component set suppressHydrationWarning = true
to wrapper element because of this kind of warning. But when use renderProps, <Media />
doesn't render any wrapper element so can't set suppressHydrationWarning
.
https://github.com/artsy/fresnel/blob/master/src/Media.tsx#L470-L476
The solution should be that renderChildren is always true on the hydration of the client and then turns false in the second step if the breakpoints do not match.
I think this might be cause side-effects of the child components. If we render child component on hydration, those components all hooks and lifecycle will be called once (which is not expected).
My workaround is to put suppressHydrationWarning
on the custom wrapper element.
Setting suppressHydrationWarning
is of course no solution, but just hides the problem. The solution is to introduce a state in the component that is set to true on mount and only then hides the elements. I will work on a PR for this.
Does anyone know if the PR was introduced?
I have the same issue as #165. This ticket was closed but actually this is a serious hydration error. Because the component this is working fine. The warning is not shown in production because React suppresses all the warnings there.
renderChildren
istrue
on the server andfalse
on the client for the specified breakpoints. This leads to a is a mismatch. As pointed out in the other issue in theThe solution should be that
renderChildren
is alwaystrue
on the hydration of the client and then turnsfalse
in the second step if the breakpoints do not match.