From 227e84c24867deff34d51b686ba4aa9c61ac11d7 Mon Sep 17 00:00:00 2001 From: lingxuan630 Date: Mon, 20 Aug 2018 21:05:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3react-lifecycles-compat?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=AF=86=E5=88=AB=E7=BB=84=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/reactjs/react-lifecycles-compat/blob/master/index.js#L53 在目前的版本,编译之后`isReactComponent`并不能在`Component.prototype`中找到,到时使用到react-lifecycles-compat的组件都无法在nerv正常运行。 --- packages/nerv/src/component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nerv/src/component.ts b/packages/nerv/src/component.ts index e55a289c..c72b328f 100644 --- a/packages/nerv/src/component.ts +++ b/packages/nerv/src/component.ts @@ -22,7 +22,9 @@ class Component implements ComponentLifecycle { // 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) { From 1a0fc5586a588e4100c093dbfd8e01e443e20e87 Mon Sep 17 00:00:00 2001 From: lingxuan630 Date: Tue, 21 Aug 2018 14:18:19 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BB=A5=E7=AC=A6=E5=90=88ts=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改函数格式以符合ts规范 --- packages/nerv/src/component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nerv/src/component.ts b/packages/nerv/src/component.ts index c72b328f..84e119e8 100644 --- a/packages/nerv/src/component.ts +++ b/packages/nerv/src/component.ts @@ -22,7 +22,7 @@ class Component implements ComponentLifecycle { // 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(){ + isReactComponent () { return true; } From 9f04bd52986979c874c5d6744ba896b84ee561d8 Mon Sep 17 00:00:00 2001 From: lingxuan630 Date: Tue, 21 Aug 2018 15:10:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[modify]=E4=BF=AE=E6=94=B9`isComponent`?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/nerv-shared/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nerv-shared/src/index.ts b/packages/nerv-shared/src/index.ts index f438d88a..32f2d7ca 100644 --- a/packages/nerv-shared/src/index.ts +++ b/packages/nerv-shared/src/index.ts @@ -149,7 +149,7 @@ export function isVText (node): node is VText { } export function isComponent (instance): instance is Component { - return !isInvalid(instance) && instance.isReactComponent === EMPTY_OBJ + return !isInvalid(instance) && !isNullOrUndef(instance.isReactComponent) } export function isWidget (