react-app-rewire-hot-loader

Adds the react-hot-loader to your create-react-app via react-app-rewired

  • 所有者: cdharris/react-app-rewire-hot-loader
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

react-app-rewire-hot-loader

Add the react-hot-loader to your create-react-app app via react-app-rewired.

Because who wants their app, state, and styles automatically reloading all the time?

Installation

npm install --save react-app-rewire-hot-loader

# If you don't already, you also need:
npm install --save react-app-rewired
npm install --save react-hot-loader

Usage

  1. In the config-overrides.js of the root of your project you created for react-app-rewired add this code:
const rewireReactHotLoader = require('react-app-rewire-hot-loader')

/* config-overrides.js */
module.exports = function override (config, env) {
  config = rewireReactHotLoader(config, env)
  return config
}
  1. Follow 'step 2' from https://github.com/gaearon/react-hot-loader , replicated below:

Mark your root component as hot-exported:

// App.js - react-hot-loader >= 4.5.4
import React from 'react'
import { hot } from 'react-hot-loader/root'

const App = () => <div>Hello World!</div>

export default process.env.NODE_ENV === "development" ? hot(App) : App

Old version: Prior to react-hot-loader version 4.5.4. you needed to write hot(module)(App).

react-hot-loader recommends to use the latest syntax as
"it is much more resilient to js errors you may make during development."

// App.js - react-hot-loader < 4.5.4
import React from 'react'
import { hot } from 'react-hot-loader'

const App = () => <div>Hello World!</div>

export default process.env.NODE_ENV === "development" ? hot(module)(App) : App
  1. Replace 'react-scripts' with 'react-app-rewired' in package.json
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test --env=jsdom",
    "eject": "react-app-rewired eject"
  },

That's it, you now have hot reloads!

License

Licensed under the MIT License, Copyright ©️ 2017 Chris Harris. See LICENSE.md for more information.

主要指标

概览
名称与所有者cdharris/react-app-rewire-hot-loader
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2017-11-21 10:38:59
推送于2019-04-15 07:58:54
最后一次提交2019-04-15 09:58:53
发布数2
最新版本名称v2.0 (发布于 )
第一版名称v1.0 (发布于 )
用户参与
星数213
关注者数3
派生数15
提交数33
已启用问题?
问题数14
打开的问题数6
拉请求数11
打开的拉请求数1
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?