fix: unmount component on destroy

This commit is contained in:
Mo Bitar
2021-11-10 08:30:38 -06:00
parent 73b91e5964
commit ba4fbd1c0a
3 changed files with 22 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import { FunctionComponent, h, render } from 'preact';
import { unmountComponentAtNode } from 'preact/compat';
import { StateUpdater, useCallback, useState } from 'preact/hooks';
import { useEffect } from 'react';
@@ -70,6 +71,9 @@ export function toDirective<Props>(
$onChanges() {
render(h(component, $scope), $element[0]);
},
$onDestroy() {
unmountComponentAtNode($element[0]);
},
};
},
],