| 1 |
/** |
| 2 |
* WordPress dependencies. |
| 3 |
*/ |
| 4 |
import { createRoot, render } from '@wordpress/element'; |
| 5 |
|
| 6 |
/** |
| 7 |
* Internal dependencies. |
| 8 |
*/ |
| 9 |
import { AppContext } from './context'; |
| 10 |
import SynonymsEditor from './components/SynonymsEditor'; |
| 11 |
|
| 12 |
const SELECTOR = '#synonym-root'; |
| 13 |
|
| 14 |
/** |
| 15 |
* Get Root. |
| 16 |
* |
| 17 |
* @returns {Element|false} Root element |
| 18 |
*/ |
| 19 |
const getRoot = () => document.querySelector(SELECTOR) || false; |
| 20 |
|
| 21 |
if (typeof createRoot === 'function') { |
| 22 |
const root = createRoot(getRoot()); |
| 23 |
root.render( |
| 24 |
<AppContext> |
| 25 |
<SynonymsEditor /> |
| 26 |
</AppContext>, |
| 27 |
); |
| 28 |
} else { |
| 29 |
render( |
| 30 |
<AppContext> |
| 31 |
<SynonymsEditor /> |
| 32 |
</AppContext>, |
| 33 |
getRoot(), |
| 34 |
); |
| 35 |
} |
| 36 |
|