Open svicalifornia opened 5 years ago
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
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.)