Skip to content

Instantly share code, notes, and snippets.

@twilson63
Created July 3, 2018 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilson63/838595dad3baef2849076f7be408cbfd to your computer and use it in GitHub Desktop.
Save twilson63/838595dad3baef2849076f7be408cbfd to your computer and use it in GitHub Desktop.
Parcel and Hot Module Reloading for React

Note to Self

React HMR using Parcel

Enabling HMR for React using Parcel steps:

  1. Install dev dependencies
yarn add babel-preset-env babel-preset-react babel-plugin-transform-class-properties --dev
  1. Install dependencies
yarn add react-hot-loader
  1. create .babelrc
{
  "presets": ["env", "react"],
  "plugins": ["react-hot-loader/babel", "transform-class-properties"]
}
  1. add hot module to the app or root component
import React from 'react'
import { hot } from 'react-hot-loader'

const App = () => {
  return <h1>React FooBar</h1>
}

export default hot(module)(App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment