-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HMR results in duplicate elements #4
Comments
According to this thread the code below works for me: main.tsx import { app } from 'hyperapp'
import { actions, state, view } from '@app/app'
import moisturize from 'hyperapp-moisturize'
function makeHotReloader (updateApp) {
return (fileName, updateAs) => {
return module.hot.accept(`./${fileName}`, () => {
import(`./${fileName}?${Date.now()}`)
.then((imported) => {
updateApp({
[updateAs]: imported.default
})
})
})
}
}
const main = moisturize(app)(state, actions, view, document.body)
const hotReloader = makeHotReloader(main.updateApp)
hotReloader('state.js', 'newState')
hotReloader('actions.js', 'newActions')
hotReloader('view.js', 'newView') Example taken from okwolf/srvs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce:
yarn
andnpm start
src/App.tsx
Logo
element) and save fileLogo
element back at line 13 and save file(Strangely, after saving the file a third time, the duplicate logos disappear, and the app looks right again.)
The text was updated successfully, but these errors were encountered: