PageTransitionEvent???????? THEY MADE MY HTML TYPES WOKE

This commit is contained in:
amy 2024-06-24 04:06:48 +03:30
parent 5e812f3a08
commit bec0aaa263
2 changed files with 28 additions and 1 deletions

21
src/components/events.tsx Normal file
View 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;

View file

@ -2,7 +2,13 @@
import { render } from 'solid-js/web'
import App from './App'
import ReloadOnBack from './components/events'
const root = document.getElementById('root')
render(() => <App />, root!)
render(() => (
<>
<ReloadOnBack />
<App />
</>
), root!)