Skip to content

Commit

Permalink
FIX update react render (#1322)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jan 29, 2023
1 parent ac3415c commit 0dfc61e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssembed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-file.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssmedia.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/src/entwine/TinyMCE_ssembed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global tinymce, window */
import jQuery from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { loadComponent } from 'lib/Injector';
import ShortcodeSerialiser, { sanitiseShortCodeProperties } from 'lib/ShortcodeSerialiser';
Expand Down
1 change: 0 additions & 1 deletion client/src/entwine/TinyMCE_ssmedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import jQuery from 'jquery';
import i18n from 'i18n';
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import Injector, { loadComponent } from 'lib/Injector';
import InsertMediaModal from 'containers/InsertMediaModal/InsertMediaModal';
Expand Down
17 changes: 12 additions & 5 deletions client/src/entwine/UploadField/UploadFieldEntwine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global window */
import jQuery from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { schemaMerge } from 'lib/schemaFieldValues';
import { loadComponent } from 'lib/Injector';
Expand Down Expand Up @@ -31,7 +30,11 @@ jQuery.entwine('ss', ($) => {
onunmatch() {
this._super();
// solves errors given by ReactDOM "no matched root found" error.
ReactDOM.unmountComponentAtNode(this.siblings('.uploadfield-holder')[0]);
const root = this.getReactRoot();
if (root) {
root.unmount();
this.setReactRoot(null);
}
},

onmatch() {
Expand Down Expand Up @@ -66,13 +69,17 @@ jQuery.entwine('ss', ($) => {
const UploadField = this.getComponent();

// TODO: rework entwine so that react has control of holder
ReactDOM.render(
let root = this.getReactRoot();
if (!root) {
root = createRoot(this.getContainer());
this.setReactRoot(root);
}
root.render(
<UploadField
{...props}
onChange={onChange}
noHolder
/>,
this.getContainer()
/>
);
},

Expand Down

0 comments on commit 0dfc61e

Please sign in to comment.