-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Custom field component value not retained across renders #624
Comments
Hey @GeorgeyB — this is strange. Do you have any other fields that may be impacting the data of this specific field's We will test around with custom fields within array fields, but we've got a lot of these in use across many projects and haven't seen this specific issue. If you use this exact field at the top level of the document, does the problem persist? What if you use it within a group? Does the problem only present itself when you use this component within an array field? Let us report back shortly. |
@jmikrut Good catch. The issue doesn't seem to occur when the component is for a top-level field - though even at the top level, the value seems to clear after an arbitary amount of time and then never again. Here's a screen recording to try and demonstrate: firefox_K8wH2ea5kN.mp4 |
I was able to reproduce the issue. The bug was introduced when we changed In your code @GeorgeyB As an aside, having |
Thanks @DanRibbens! I can confirm that this works as expected with your fix. |
Hi @DanRibbens, this change seems to prevent any native React hooks from functioning correctly. Using this minimal example:
Throws a The same error occurs with other native hooks too due to React's |
Hey @GeorgeyB I can't reproduce this in I suspect that your package.json has an issue with 1. You might have mismatching versions of React and the renderer Would you mind sharing a repo that recreates this or a branch from Payload that shows it in edit: you also can run into the issue when you link payload on a project as you end up with more than one react in node_modules. You can add an alias for react in webpack as a workaround but it is annoying to deal with. |
Hi @DanRibbens, apologies for the delay coming back to you. React hooks are working as expected, but I'm still experiencing the initial issue whereby values are being lost between renders. I've been able to reproduce this in a completely fresh Payload install:
Where
The value shows in the input until the parent array field rerenders, then it is lost. It's worth noting that even if |
Hey @GeorgeyB I haven't published the fix yet in the latest version yet. There were some other big changes merged at the same time and we wanted to do some additional QA on it first. I'll update again when its released. |
@GeorgeyB — the fix is now deployed in Will you give it a shot, and if it resolves the problem you're facing, will you close this issue? |
Looking good now, thanks guys. |
This issue has been automatically locked. |
Hi guys, I'm trying to swap out a field component, but the value doesn't seem to be retained between renders. Any ideas? Here's a component I'm using in its simplest form:
As soon as a rerender occurs (in this case, my cursor leaves the parent array field) the value is lost.
The text was updated successfully, but these errors were encountered: