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

CMS 5: UploadFieldEntwine.js uses deprecated ReactDOM.render() #1313

Open
3 tasks
GuySartorelli opened this issue Dec 12, 2022 · 0 comments
Open
3 tasks

CMS 5: UploadFieldEntwine.js uses deprecated ReactDOM.render() #1313

GuySartorelli opened this issue Dec 12, 2022 · 0 comments

Comments

@GuySartorelli
Copy link
Member

silverstripe/silverstripe-admin#1312 involved updating a lot of code, but some work was left undone.

src/entwine/UploadField/UploadFieldEntwine.js defines how entwine hooks result in the react UploadField being added to the DOM.
It includes a deprecated use of ReactDOM.render() in its refresh() function.

This was necessary because replacing it with the new React 18 createRoot() syntax resulted in an infinite loop any time a form in the CMS was submitted which included changes to the value of an UploadField (e.g. add a file and then save page, or remove file and then save page).
Worth noting here that the form submission did work correctly - refreshing the page shows the new value. So it's purely a react rendering issue after the submission has occurred - possibly some race condition between react and entwine.

Replace the ReactDOM.render() syntax with createRoot(), and refactor whatever needs refactoring to avoid the infinite loop on form submissions.

Acceptance Criteria

  • We don't use the deprecated ReactDOM.render()
  • The upload field works correctly in entwine forms
  • Forms submit correctly when saving changes to upload fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant