diff --git a/src/reconciler/componentComparator.js b/src/reconciler/componentComparator.js
index 4815644a8..23f5c9416 100644
--- a/src/reconciler/componentComparator.js
+++ b/src/reconciler/componentComparator.js
@@ -153,10 +153,14 @@ const compareComponents = (oldType, newType, setNewType, baseType) => {
}
if (isLazyType({ type: oldType })) {
+ // no need to update
+ // setNewType(newType);
return defaultResult;
}
if (isContextType({ type: oldType })) {
+ // update provider
+ setNewType(newType);
return defaultResult;
}
diff --git a/test/hot/react-dom.integration.spec.js b/test/hot/react-dom.integration.spec.js
index 666ec8065..82d0baadc 100644
--- a/test/hot/react-dom.integration.spec.js
+++ b/test/hot/react-dom.integration.spec.js
@@ -101,6 +101,64 @@ describe(`🔥-dom`, () => {
expect(unmount).toHaveBeenCalled();
});
+ it('should reload context', async () => {
+ const mount = jest.fn();
+ const unmount = jest.fn();
+
+ const genApp = contextValue => {
+ const context = React.createContext(contextValue);
+
+ const RenderContext = () => {
+ const v = React.useContext(context);
+
+ return contextValue={v};
+ };
+
+ const MountCheck = () => {
+ React.useEffect(() => {
+ mount('test1');
+ return unmount;
+ }, []);
+ return 'fun1';
+ };
+
+ const App = () => (
+
+
+
+
+
+
+
+ );
+
+ ReactHotLoader.register(context, 'context', 'test');
+
+ return App;
+ };
+
+ const el = document.createElement('div');
+ const App1 = genApp('1-test-1');
+ ReactDom.render(, el);
+
+ expect(el.innerHTML).toMatch(/1-test-1/);
+ expect(el.innerHTML).toMatch(/~1-test-1~/);
+
+ incrementHotGeneration();
+ {
+ const App1 = genApp('2-hot-2');
+ ReactDom.render(, el);
+ }
+
+ await tick();
+
+ expect(el.innerHTML).toMatch(/2-hot-2/);
+ expect(el.innerHTML).toMatch(/~2-hot-2~/);
+
+ expect(mount).toHaveBeenCalledTimes(1);
+ expect(unmount).toHaveBeenCalledTimes(0);
+ });
+
it('should reload hook effect', async () => {
const mount = jest.fn();
const unmount = jest.fn();
diff --git a/yarn.lock b/yarn.lock
index d10be210b..283bd2c27 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4594,11 +4594,6 @@ lodash@^4.0.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, l
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
integrity sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=
-lodash@^4.17.11:
- version "4.17.11"
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
- integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
-
lodash@^4.17.5:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"