Skip to content

Commit

Permalink
Support client rendering for earlier versions of React (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
halocline authored Sep 8, 2024
1 parent 1dd2169 commit 935e10f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions grommet-leaflet/src/layers/MarkerCluster/MarkerCluster.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { createRoot } from 'react-dom/client';
import { render } from 'react-dom';
import PropTypes from 'prop-types';
import { ThemeContext } from 'styled-components';
import { v4 as uuidv4 } from 'uuid';
Expand Down Expand Up @@ -74,8 +74,12 @@ const MarkerCluster = props => {
// We then render the popup's contents dynamically and replace the
// static content with an interactive ReactNode.
const domNode = document.getElementById(popupId);
const root = createRoot(domNode);
root.render(popupContent);
// Need to accomodate earlier versions of React. If <18, then
// need to use ReactDOM.render() instead of createRoot().render().
// Should drop support for <18 in the future.
render(popupContent, domNode);
// const root = createRoot(domNode);
// root.render(popupContent);
});
}

Expand Down

0 comments on commit 935e10f

Please sign in to comment.