0

What are the react api rules for React's this ?

I am asking this because I am trying to understand this code:

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

Where it is written:

 * 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.

What kind of rules do they refer to ? Where can I read those rules ?


This is the closest thing that google gives:

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

Are the rules here somewhere ?

Or is it this ?

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

jhegedus
  • 20,244
  • 16
  • 99
  • 167
  • I start to understand this : each lifeCycle state is associated with a certain type of scope : https://github.com/japgolly/scalajs-react/blob/master/doc/TYPES.md – jhegedus Sep 25 '16 at 06:34

1 Answers1

0

I want to document here what I think is the answer, not 100% sure though, this answer probably needs to be improved.

The key to understanding what Scope means is here:

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

Namely this table:

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.

So each Scope corresponds to a lifeCycle "state".

jhegedus
  • 20,244
  • 16
  • 99
  • 167