PageTransitionEvent???????? THEY MADE MY HTML TYPES WOKE
This commit is contained in:
parent
5e812f3a08
commit
bec0aaa263
2 changed files with 28 additions and 1 deletions
21
src/components/events.tsx
Normal file
21
src/components/events.tsx
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { onMount } from 'solid-js';
|
||||||
|
|
||||||
|
const ReloadOnBack = () => {
|
||||||
|
const handlePageShow = (event: Event) => {
|
||||||
|
const pageshowEvent = event as PageTransitionEvent;
|
||||||
|
if (pageshowEvent.persisted) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
window.addEventListener('pageshow', handlePageShow);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('pageshow', handlePageShow);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReloadOnBack;
|
|
@ -2,7 +2,13 @@
|
||||||
import { render } from 'solid-js/web'
|
import { render } from 'solid-js/web'
|
||||||
|
|
||||||
import App from './App'
|
import App from './App'
|
||||||
|
import ReloadOnBack from './components/events'
|
||||||
|
|
||||||
const root = document.getElementById('root')
|
const root = document.getElementById('root')
|
||||||
|
|
||||||
render(() => <App />, root!)
|
render(() => (
|
||||||
|
<>
|
||||||
|
<ReloadOnBack />
|
||||||
|
<App />
|
||||||
|
</>
|
||||||
|
), root!)
|
||||||
|
|
Loading…
Reference in a new issue