Giter VIP home page Giter VIP logo

Comments (6)

AndrewPrifer avatar AndrewPrifer commented on May 12, 2024 3

If anyone still needs this, React Hot Loader 4 is trivial to integrate. The only changes needed are

  1. A custom .babelrc:
{
  "presets": [
    "razzle/babel"
   ],
   "plugins": [
     "react-hot-loader/babel"
   ]
}
  1. Wrapping the App export in the hot HOC:
import React from 'react';
import Route from 'react-router-dom/Route';
import Switch from 'react-router-dom/Switch';
import Home from './Home';
import './App.css';

import { hot } from 'react-hot-loader'; // !!!

const App = () => (
  <Switch>
    <Route exact path="/" component={Home} />
  </Switch>
);

export default hot(module)(App); // !!!

@jaredpalmer maybe this could be made the default setup when RHL 4 is officially released?

from razzle.

jaredpalmer avatar jaredpalmer commented on May 12, 2024

Thanks! Feel free to submit a PR. I have been using react-hot-loader on other projects, seems to work
really well.

from razzle.

robbinjanssen avatar robbinjanssen commented on May 12, 2024

Cool, i'll try submitting one later this week!

from razzle.

robbinjanssen avatar robbinjanssen commented on May 12, 2024

Hi Jared,

Don't have the time atm to wrap up a PR, sorry. Since the react-hot-loader is still in development, i'll try to create it when it has been released :) Closing for now

from razzle.

bdombro avatar bdombro commented on May 12, 2024

@andrewpeterprifer THANK YOU, THIS IS AWESOME. RHL4 brings so many great features!

from razzle.

jgibo avatar jgibo commented on May 12, 2024

Adding to the solution AndrewPrifer provided above, if you need hooks support do the following.

NOTE: These steps are adapted for razzlejs from the official way to do this found here https://github.com/gaearon/react-hot-loader#hot-loaderreact-dom

  1. npm install --save @hot-loader/react-dom@YOUR-REACT-DOM-VERSION
  2. Adjust razzle.config.js to use the patched react-dom (from hot-loader) instead of the regular react-dom
// razzle.config.js

module.exports = {
  modify: (config, { target, dev }, webpack) => {
    // THIS LINE IS THE MAGIC JUICE
    config.resolve.alias['react-dom'] = '@hot-loader/react-dom'

    return config;
  },
};

from razzle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.