0

React 的 this 的 react api 规则是什么?

我问这个是因为我试图理解这段代码:

https://github.com/japgolly/scalajs-react/blob/master/core/src/main/scala/japgolly/scalajs/react/types.scala#L8

写在哪里:

 * Here we break React's `this` into tiny little bits, then stitch them together to use type-safety to enforce the
 * rules documented in the React API.

他们指的是什么样的规则?我在哪里可以阅读这些规则?


这是谷歌给出的最接近的东西:

https://facebook.github.io/react/docs/top-level-api.html

这里有规则吗?

还是这个?

https://facebook.github.io/react/docs/component-specs.html

4

1 回答 1

0

我想在这里记录我认为的答案,虽然不是 100% 肯定,但这个答案可能需要改进。

理解 Scope 含义的关键在这里:

https://github.com/japgolly/scalajs-react/blob/master/doc/TYPES.md

即这张表:

Type                                 Desc
CompScope.DuringCallbackU[P, S, +B] An unmounted component's this scope.
CompScope.DuringCallbackM[P, S, +B] A mounted component's this scope.
CompScope.WillUpdate[P, S, +B, +N]  A component's this scope during componentWillUpdate.
BackendScope[P, S]                  A component's this scope as is available to backends.

所以每个Scope对应一个lifeCycle“状态”。

于 2016-09-25T06:37:43.780 回答