-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: React16.6 compatibility #1084
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3284f1e
feat: React16.6 compatibility
theKashey cc57beb
spike React.lazy support
theKashey 9f1e546
Merge remote-tracking branch 'origin/master' into react-16-6
theKashey 5c921b2
update example and make it complex
theKashey b96b6c0
support react.lazy
theKashey 5a71512
unstable memo test
theKashey 008ff02
wrap render with try/catch to mitigate error from suspense and hooks
theKashey f0b91e3
put example in dev mode
theKashey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* eslint-disable no-use-before-define */ | ||
import { isCompositeComponent } from './internal/reactUtils' | ||
import { isCompositeComponent, isMemoType } from './internal/reactUtils' | ||
import { increment as incrementGeneration } from './global/generation' | ||
import { | ||
updateProxyById, | ||
|
@@ -16,7 +16,15 @@ import logger from './logger' | |
|
||
import { preactAdapter } from './adapters/preact' | ||
|
||
function resolveType(type) { | ||
const forceSimpleSFC = { proxy: { allowSFC: false } } | ||
|
||
function resolveType(type, options = {}) { | ||
if (isMemoType({ type })) { | ||
return { | ||
...type, | ||
type: resolveType(type.type, forceSimpleSFC), | ||
} | ||
} | ||
if ( | ||
!isCompositeComponent(type) || | ||
isTypeBlacklisted(type) || | ||
|
@@ -26,13 +34,13 @@ function resolveType(type) { | |
|
||
const proxy = reactHotLoader.disableProxyCreation | ||
? getProxyByType(type) | ||
: createProxyForType(type) | ||
: createProxyForType(type, options) | ||
|
||
return proxy ? proxy.get() : type | ||
} | ||
|
||
const reactHotLoader = { | ||
register(type, uniqueLocalName, fileName) { | ||
register(type, uniqueLocalName, fileName, options = {}) { | ||
if ( | ||
isCompositeComponent(type) && | ||
typeof uniqueLocalName === 'string' && | ||
|
@@ -62,9 +70,17 @@ const reactHotLoader = { | |
configuration.onComponentRegister(type, uniqueLocalName, fileName) | ||
} | ||
|
||
updateProxyById(id, type) | ||
updateProxyById(id, type, options) | ||
registerComponent(type) | ||
} | ||
if (isMemoType({ type })) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably the same magic is needed for Context |
||
reactHotLoader.register( | ||
type.type, | ||
uniqueLocalName, | ||
fileName, | ||
forceSimpleSFC, | ||
) | ||
} | ||
}, | ||
|
||
reset() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.memo could "eat" only simple class or functional component.
The current approach, with "indeterminate" components is breaking the stuff.