Skip to content

Commit

Permalink
Follow up React 18
Browse files Browse the repository at this point in the history
- ReactDOM.hydrate is no longer supported in React 18
  • Loading branch information
dantovbein committed Apr 24, 2023
1 parent 8d7fe53 commit d803524
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/src/functions/hydrateBlock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {hydrate} from 'react-dom';
import {hydrateRoot as hydrate} from 'react-dom';

/**
* This function hydrate a SSR Component
Expand All @@ -13,7 +13,9 @@ export const hydrateBlock = (blockName, Component, csrAttributes = {}) => { // e
blocks.forEach(
blockNode => {
const attributes = JSON.parse(blockNode.dataset.attributes);
hydrate(<Component {...attributes} {...csrAttributes} />, blockNode);
if(blockNode.length) {
hydrate(<Component {...attributes} {...csrAttributes} />, blockNode);
}
}
);
};

0 comments on commit d803524

Please sign in to comment.