Skip to content

Commit

Permalink
alter tail update message and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Sep 23, 2019
1 parent d4b2fd5 commit 9e50b7c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ const Hello = () => 'Hello';
export default hot(Hello); // <-- module will reload itself
```

To support any code splitting library RHL uses a special _tail update detection_ logic -
if some components would be requested after initial HMR event - Application would be updated yet again to
apply possible change.
In this case you will see a message `React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes.`.

If this is not something you want or need - you might disable this behavior by setting `setConfiguration({trackTailUpdates:false})` to disable it.

### Checking Element `type`s

Because React Hot Loader creates proxied versions of your components, comparing
Expand Down
3 changes: 0 additions & 3 deletions src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ const configuration = {
// flag to completely disable RHL for SFC. Probably don't use it without dom patch made.
ignoreSFC: false,

// flag to disable special treatment for React.lazy
ignoreLazy: false,

// ignoreSFC when injection into react-dom is made
ignoreSFCWhenInjected: true,

Expand Down
2 changes: 1 addition & 1 deletion src/reconciler/fiberUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { resolveType } from './resolver';
const lazyConstructor = '_ctor';

const patchLazyConstructor = target => {
if (!configuration.ignoreLazy && !target[lazyConstructor].isPatchedByReactHotLoader) {
if (!configuration.trackTailUpdates && !target[lazyConstructor].isPatchedByReactHotLoader) {
const ctor = target[lazyConstructor];
target[lazyConstructor] = () =>
ctor().then(m => {
Expand Down
6 changes: 6 additions & 0 deletions test/hot/react-dom.integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe(`🔥-dom`, () => {
expect(el.innerHTML).toEqual('fun2');

expect(mount).toHaveBeenCalledWith('test1');
// THIS TEST IS EXPECTED TO FAIL ON LOCAL MACHINE (have no idea why)!!
expect(mount).not.toHaveBeenCalledWith('test2');
expect(unmount).not.toHaveBeenCalled();
});
Expand Down Expand Up @@ -237,6 +238,7 @@ describe(`🔥-dom`, () => {
}

await tick();
// THIS TEST IS EXPECTED TO FAIL ON LOCAL MACHINE (have no idea why)!!
expect(el.innerHTML).toEqual('test1');

incrementHotGeneration();
Expand Down Expand Up @@ -340,6 +342,10 @@ describe(`🔥-dom`, () => {
});

it('support lazy memo forward in Provider', () => {
setConfig({
trackTailUpdates: false,
});

const spy = jest.fn();
const sandbox = x => {
const Comp = () => {
Expand Down
4 changes: 4 additions & 0 deletions test/hot/react-dom.no-integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ describe(`🔥-dom`, () => {
});

it('support lazy memo forward', () => {
setConfig({
trackTailUpdates: false,
});

const spy = jest.fn();
const sandbox = x => {
const Comp = () => {
Expand Down

0 comments on commit 9e50b7c

Please sign in to comment.