File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ options._diff = vnode => {
3737} ;
3838
3939options . _root = ( vnode , parentDom ) => {
40- if ( parentDom . _children && parentDom . _children . _mask ) {
40+ if ( vnode && parentDom . _children && parentDom . _children . _mask ) {
4141 vnode . _mask = parentDom . _children . _mask ;
4242 }
4343
Original file line number Diff line number Diff line change @@ -456,4 +456,25 @@ describe('useId', () => {
456456 '<div><div>My id is P0-0</div><div>My id is P0-1</div></div>'
457457 ) ;
458458 } ) ;
459+
460+ it ( 'should not crash for rendering null after a non-null render' , ( ) => {
461+ const Id = ( ) => {
462+ const id = useId ( ) ;
463+ return < div > My id is { id } </ div > ;
464+ } ;
465+
466+ const App = props => {
467+ return (
468+ < div >
469+ < Id />
470+ { props . secondId ? < Id /> : null }
471+ </ div >
472+ ) ;
473+ } ;
474+
475+ render ( createElement ( App , { secondId : false } ) , scratch ) ;
476+ expect ( scratch . innerHTML ) . to . equal ( '<div><div>My id is P0-0</div></div>' ) ;
477+ render ( null , scratch ) ;
478+ expect ( scratch . innerHTML ) . to . equal ( '' ) ;
479+ } ) ;
459480} ) ;
You can’t perform that action at this time.
0 commit comments