{"id":23545191,"url":"https://github.com/dgeibi/dva-hot","last_synced_at":"2025-04-24T03:12:52.170Z","repository":{"id":57217306,"uuid":"117088046","full_name":"dgeibi/dva-hot","owner":"dgeibi","description":"HMR plugin for dva without babel","archived":false,"fork":false,"pushed_at":"2019-06-07T14:36:12.000Z","size":360,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T03:12:45.590Z","etag":null,"topics":["dva","hmr-plugin","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgeibi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-11T10:53:45.000Z","updated_at":"2020-05-27T05:51:10.000Z","dependencies_parsed_at":"2022-08-28T21:40:32.766Z","dependency_job_id":null,"html_url":"https://github.com/dgeibi/dva-hot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeibi%2Fdva-hot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeibi%2Fdva-hot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeibi%2Fdva-hot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgeibi%2Fdva-hot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgeibi","download_url":"https://codeload.github.com/dgeibi/dva-hot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250552076,"owners_count":21449165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dva","hmr-plugin","webpack"],"created_at":"2024-12-26T08:15:24.133Z","updated_at":"2025-04-24T03:12:52.147Z","avatar_url":"https://github.com/dgeibi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dva-hot\n\n[![version][version-badge]][package]\n\nHMR plugin for dva without babel inspired by [babel-plugin-dva-hmr](https://github.com/dvajs/babel-plugin-dva-hmr) and [react-hot-loader](https://github.com/gaearon/react-hot-loader).\n\n## Install\n\n``` sh\n$ npm install dva-hot\n```\n\n## Usage\n\n**Patch App**\n\n``` js\nimport hot from 'dva-hot'\nimport dva from 'dva'\n\nconst app = dva()\n\nhot.patch(app) // you must patch `app` before calling app.{model,router,start}\n\napp.model(require('./models/a').default)\napp.model(require('./models/b').default)\napp.router(require('./router').default)\n\napp.start('#root')\n```\n\nAfter `dva@2.2.2`, the usage below should work:\n\n``` js\nimport hot from 'dva-hot'\nimport dva from 'dva'\nimport { createElement } from 'react'\nimport { render } from 'react-dom'\n\nconst app = dva()\n\nhot.patch(app) // you can pass container to hot.patch like `hot.patch(app, container)`\n\napp.model(require('./models/a').default)\napp.model(require('./models/b').default)\napp.router(require('./router').default)\n\n// After dva@2.2.2: pass container for HMR\nrender(createElement(app.start()), hot.setContainer('#root'))\n// or\n// render(createElement(app.start()), hot.setContainer(document.querySelector('#root')))\n```\n\n**Self-accepted Router**\n\n``` js\nimport React from 'react'\nimport { routerRedux } from 'dva/router'\nimport { renderRoutes } from 'react-router-config'\nimport hot from 'dva-hot'\nimport routes from '../routes'\n\nconst { ConnectedRouter } = routerRedux\n\nfunction RouterConfig({ history }) {\n  return \u003cConnectedRouter history={history}\u003e{renderRoutes(routes)}\u003c/ConnectedRouter\u003e\n}\n\nexport default hot.router(module)(RouterConfig)\n```\n\n**Self-accepted Model**\n\n``` js\nimport hot from 'dva-hot'\n\nexport default hot.model(module)({\n  namespace: 'a-dva-model'\n  state: [],\n  // upgrade to dva@2.2.2 if you use models that without `reducers`\n})\n```\n\n## LICENSE\n\n[ISC](LICENSE)\n\n[version-badge]: https://img.shields.io/npm/v/dva-hot.svg\n[package]: https://www.npmjs.com/package/dva-hot\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgeibi%2Fdva-hot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgeibi%2Fdva-hot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgeibi%2Fdva-hot/lists"}