Skip to content

Commit e0973c1

Browse files
committed
Only render once a plugin instance is prepared
1 parent 0c2c6fa commit e0973c1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

example/r3f/plugins/ImageOverlayPlugin.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const ImageOverlay = forwardRef( function ImageOverlay( props, ref ) {
3636

3737
useEffect( () => {
3838

39-
if ( ! plugin ) return;
4039
plugin.addOverlay( overlay, order );
4140

4241
return () => {
@@ -49,7 +48,6 @@ export const ImageOverlay = forwardRef( function ImageOverlay( props, ref ) {
4948

5049
useEffect( () => {
5150

52-
if ( ! plugin ) return;
5351
plugin.setOverlayOrder( overlay, order );
5452

5553
}, [ overlay, plugin, order ] );

src/r3f/components/TilesRenderer.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ export const TilesPlugin = forwardRef( function TilesPlugin( props, ref ) {
200200
// assign ref
201201
useApplyRefs( instance, ref );
202202

203+
// only render out the plugin once the instance and context are ready
204+
if ( ! instance ) {
205+
206+
return;
207+
208+
}
209+
203210
return <TilesPluginContext.Provider value={ instance }>{ children }</TilesPluginContext.Provider>;
204211

205212
} );
@@ -270,7 +277,7 @@ export const TilesRenderer = forwardRef( function TilesRenderer( props, ref ) {
270277
// assign options recursively
271278
useDeepOptions( tiles, options );
272279

273-
// if the tiles have not been created yet then don't render any children
280+
// only render out the tiles once the instance and context are ready
274281
if ( ! tiles ) {
275282

276283
return null;

0 commit comments

Comments
 (0)