React Hot Patching

 react-hot-loader works by binding the original module to any new code, whether it be functions, classes, or methods. It will patch all of the methods of React components to use the new methods.

The question this leaves is how to patch the original module. Things will get extremely complicated if you try to accept an update. For instance, if you change code inside a closure, it becomes hard to patch the closure without losing the existing state. It may be achievable to use the React engine's debugger API but to make this change throughout may be difficult: how difficult will depend greatly on your specific context.

Note that when patching closures, only allowing very basic patching is best as it's intuitively easy to keep track of how everything works.

We often have to patch code when it's a complex and custom project. One tool that is very common with Webpack is an innate patching tool called eval. We will take a closer look at that now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.248.119