Skip to content
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

解决react-lifecycles-compat无法识别组件的问题 #89

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nerv-shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function isVText (node): node is VText {
}

export function isComponent (instance): instance is Component<any, any> {
return !isInvalid(instance) && instance.isReactComponent === EMPTY_OBJ
return !isInvalid(instance) && !isNullOrUndef(instance.isReactComponent)
}

export function isWidget (
Expand Down
4 changes: 3 additions & 1 deletion packages/nerv/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Component<P, S> implements ComponentLifecycle<P, S> {
// Is a React Component.
// tslint:disable-next-line:max-line-length
// see: https://github.com/facebook/react/blob/3c977dea6b96f6a9bb39f09886848da870748441/packages/react/src/ReactBaseClasses.js#L26
isReactComponent = EMPTY_OBJ
isReactComponent () {
return true;
}

constructor (props?: P, context?: any) {
if (!this.state) {
Expand Down