Closed Riyad-Arafat closed 1 year ago
@riyadelberkawy Hey, I can't reproduce placeholder flickering on rerender. I have created a sandbox with provided code snipped: https://codesandbox.io/s/blazing-sunset-zk7dw4
Please, check if you can see flickering in this example. (or modify this sandbox to reproduce the bug you encountered if you have a chance :pray:)
@goveo Hi, I modified the sandbox you provided and was able to reproduce the issue. You can see it here: https://codesandbox.io/s/quizzical-golick-1241hk To reproduce the issue, you need to re-rendering the entire form by toggling the visibility of the form by clicking on the show and hide buttons. Let me know if you need anything else to help diagnose this problem. Thank you!
@riyadelberkawy Should be fixed in version 1.8.4 https://codesandbox.io/s/admiring-edison-zsogwo
Please provide any feedback if the issue still persists
@goveo Thank you for fixing the issue π₯³ I have tested the changes in the provided codesandbox and it seems to be working as expected. I appreciate your prompt response and effort in resolving the issue. Let me know if there's anything else I can do to assist. Thank you again!
@goveo Sorry about that but I noticed that the issue occurs again when I add an initial value for the phone field in the form. https://codesandbox.io/s/quizzical-golick-1241hk
That happened because useWatch
returns undefined
on the first render.
You can simply add a check for undefined:
https://codesandbox.io/s/eager-proskuriakova-vv3kr2?file=/src/PhoneInput.tsx:607-639
Also, the country guessing on the initial render was slightly fixed in version 1.8.5, so I have updated the example to it. Can you check if this solved your problem, please?
@riyadelberkawy
UPD: I have changed the usage of Form.useWatch
to just form.getFieldValue
and everything seems like work as expected:
const value = Form.useWatch(props?.name || "");
to
const value = form.getFieldValue(props?.name || "");
@goveo it's working properly now. π Thanks for your effort.
π Thank you for your effort!
β Consider leaving a star on this repo if you like the project.
I'm writing to report a bug I encountered while using the "react-international-phone" package. The issue is related to the placeholder value that is being displayed every time the component re-renders.
Specifically, when the component has a value, the placeholder is displayed briefly before the actual value is shown. This behavior occurs every time the component re-renders, causing a noticeable flicker.
I have tried to address this issue on my end, but without success. I would like to request your assistance in resolving this problem. I'm happy to provide any additional information or to assist in any way I can.
The following snippet produces the issue.