Skip to content

Commit

Permalink
Fix null access error in conditional display handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
atanas-vasilev-dev committed Jul 23, 2024
1 parent 0103f0d commit 155346c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function handler( { containers, context } ) {
results.forEach( ( [ id, result ] ) => {
const postboxNode = document.getElementById( id );
const containerNode = document.querySelector( `.container-${ id }` );
const isMounted = !! containerNode.dataset.mounted;
const isMounted = !! containerNode?.dataset?.mounted;

if ( postboxNode ) {
postboxNode.hidden = ! result;
Expand All @@ -119,10 +119,10 @@ export default function handler( { containers, context } ) {
if ( result && ! isMounted ) {
renderContainer( containers[ id ], context );
}

if ( ! result && isMounted ) {
delete containerNode?.dataset?.mounted;

// Rely on React's internals instead of `unmountComponentAtNode`
// due to https://github.com/facebook/react/issues/13690.
// TODO: Conditionally render the fields in the container, this way
Expand Down

0 comments on commit 155346c

Please sign in to comment.