Skip to content

Commit

Permalink
Replace ReactDOM.render with createRoot from wp.element, #1506
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Dec 15, 2023
1 parent d99f66e commit b404ba1
Show file tree
Hide file tree
Showing 5 changed files with 465 additions and 14,244 deletions.
2 changes: 2 additions & 0 deletions modules/calendar/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ public function enqueue_admin_scripts()
true
);

// TODO: Replace react and react-dom with the wp.element dependency
wp_enqueue_script(
'publishpress-async-calendar-js',
$this->module_url . 'lib/async-calendar/js/index.min.js',
Expand All @@ -665,6 +666,7 @@ public function enqueue_admin_scripts()
'jquery-ui-droppable',
'jquery-inputmask',
'wp-i18n',
'wp-element',
'date_i18n',
],
PUBLISHPRESS_VERSION,
Expand Down
11 changes: 7 additions & 4 deletions modules/calendar/lib/async-calendar/js/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import AsyncCalendar from "./AsyncCalendar";
import {getDateWithNoTimezoneOffset, getDateInstanceFromString} from "./Functions";
import { getDateWithNoTimezoneOffset, getDateInstanceFromString } from "./Functions";
import { createRoot } from "@wp.element";

jQuery(() => {
ReactDOM.render(
const container = document.getElementById('publishpress-calendar-wrap');
const root = createRoot(container);

root.render(
<AsyncCalendar
firstDateToDisplay={getDateWithNoTimezoneOffset(publishpressCalendarParams.firstDateToDisplay)}
weekStartsOnSunday={parseInt(publishpressCalendarParams.weekStartsOnSunday) === 1}
Expand All @@ -25,7 +29,6 @@ jQuery(() => {
items={publishpressCalendarParams.items}
allowAddingMultipleAuthors={publishpressCalendarParams.allowAddingMultipleAuthors}
requestFilter={publishpressCalendarParams.requestFilter}
strings={publishpressCalendarParams.strings}/>,
document.getElementById('publishpress-calendar-wrap')
strings={publishpressCalendarParams.strings} />
);
});
438 changes: 435 additions & 3 deletions modules/calendar/lib/async-calendar/js/index.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit b404ba1

Please sign in to comment.