Packages

t

react

React

trait React extends AnyRef

Scala-side access to JSReact APIs. Some of these methods overlay the raw JS version to provide the convenience of using scala types as inputs and saving a few conversion nits.

Some of the *N() hook functions like useCallback may be quite inefficient in their conversion from scala functions to js functions and back. Perhaps we need another parallel API function set with the js functions being assumed for those code bases that already have the js versions. Note that useCallback returns a js function so it can be used as a dependency.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. React
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. def cloneElement(element: ReactElement, props: Object): ReactElement

    Clone a ReactElement and add new props.

    Clone a ReactElement and add new props. You should not use this if you can avoid it.

  7. def createContext[T](defaultValue: T): ReactContext[T]
  8. def createDOMElement(tag: String, props: |[Object, Dynamic])(children: ReactNode*): ReactDOMElement

    Create a DOM element using the string name e.g.

    Create a DOM element using the string name e.g. "div".

  9. def createElement[P <: Object](component: ReactType, props: P, children: ReactNode*): ReactElement

    Create an element using the standard var args signature.

  10. def createElement[P <: Object](component: ReactType, props: P): ReactElement

    Create an element with some props.

    Create an element with some props. Children can be in the props.

  11. def createElement0(tag: ReactType, props: |[Object, Dynamic]): ReactElement

    Create an element with props and 0 children.

  12. def createElement1(tag: ReactType, props: |[Object, Dynamic], child: ReactNode): ReactElement

    Create an elemnt with 1 child only.

  13. def createElementN(tag: ReactType)(children: ReactNode*): ReactElement

    Create an element without props but with children as a separate parameter.

  14. def createElementN(tag: ReactType, props: |[Object, Dynamic])(children: ReactNode*): ReactElement

    Create an element with props and children.

  15. def createFragment(key: Option[String], children: ReactNode*): ReactElement

    Create a react fragment.

    Create a react fragment. Fragments are created as an "element" with a specific tag (symbol or number if target does not support symbol) vs say, the string "div".

  16. def createMutableSource[S](source: Any, getVersion: Function0[Any]): MutableSource[S]
  17. def createRef[T](): ReactRef[T]

    Create a ReactRef.

  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  20. def extractChildren(item: UndefOr[Object]): Array[ReactNode]

    Given a js.Object (or subclass), find a "children" property and assume its an array of ReactNodes.

    Given a js.Object (or subclass), find a "children" property and assume its an array of ReactNodes. If not found, return an empty js array. This function is used for interop where your scala "make" method takes children as a separate parameter but your props (event JS friendly props) does not contain the children property--it's there if there are children on the js side. This is not needed in scalajs-react because the children are passed and managed explicitly.

    Annotations
    @inline()
    To do

    Seems like this is an expensive call. Can we do better?

  21. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  22. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  23. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  24. def lazy(lazyComponent: DynamicImportThunk): ReactJSLazyComponent
  25. def memo[P <: Object](fc: Function1[P, ReactNode], compare: Function2[UndefOr[P], UndefOr[P], Boolean]): Function1[P, ReactNode]

    Memoize with a function and a comparator.

  26. def memo[P <: Object](fc: Function1[P, ReactNode]): Function1[P, ReactNode]

    Memoize a function.

  27. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  29. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  30. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. def unsafeCreateElement(component: (Dynamic) => ReactNode, props: Dynamic): ReactElement
  33. def unsafeCreateElement(component: () => ReactNode): ReactElement

    For creating quick ReactElements using js.Dynamic.

    For creating quick ReactElements using js.Dynamic. Input is a scala function taking a single props argument.

  34. def useCallback[T](dependencies: AllType*)(callback: Function0[T]): Function0[T]
  35. def useCallback1[A1, T](dependencies: AllType*)(callback: Function1[A1, T]): Function1[A1, T]
  36. def useCallback1A[A1, T](dependencies: Dependencies)(callback: Function1[A1, T]): Function1[A1, T]
  37. def useCallback2[A1, A2, T](dependencies: AllType*)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
  38. def useCallback2A[A1, A2, T](dependencies: Dependencies)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
  39. def useCallback3[A1, A2, A3, T](dependencies: AllType*)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
  40. def useCallback3A[A1, A2, A3, T](dependencies: Dependencies)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
  41. def useCallback4[A1, A2, A3, A4, T](dependencies: AllType*)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
  42. def useCallback4A[A1, A2, A3, A4, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
  43. def useCallback5[A1, A2, A3, A4, A5, T](dependencies: AllType*)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
  44. def useCallback5[A1, A2, A3, A4, A5, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
  45. def useCallbackA[T](dependencies: |[Dependencies, Unit])(callback: Function0[T]): Function0[T]
  46. def useCallbackMounting[T](callback: Function0[T]): Function0[T]
  47. def useCallbackMounting1[A1, T](callback: Function1[A1, T]): Function1[A1, T]
  48. def useCallbackMounting2[A1, A2, T](callback: Function2[A1, A2, T]): Function2[A1, A2, T]
  49. def useCallbackMounting3[A1, A2, A3, T](callback: Function3[A1, A2, A3, T]): Function3[A1, A2, A3, T]
  50. def useCallbackMounting4[A1, A2, A3, A4, T](callback: Function4[A1, A2, A3, A4, T]): Function4[A1, A2, A3, A4, T]
  51. def useCallbackMounting5[A1, A2, A3, A4, A5, T](callback: Function5[A1, A2, A3, A4, A5, T]): Function5[A1, A2, A3, A4, A5, T]
  52. def useContext[T](context: ReactContext[T]): T
  53. def useDebugValue[T](value: T, format: (T) => String): Unit
  54. def useDebugValue[T](value: T): Unit
  55. def useDeferredValue[T](value: T, t: Int): T
  56. def useDeferredValue[T](value: T, config: DeferredValueConfig): T

    Use a deferred value.

    Use a deferred value. Config indicates how long the value is good for.

  57. def useEffect(dependencies: AllType*)(didUpdate: EffectArg): Unit

    Effect is run when dependencies change.

  58. def useEffectA(dependencies: Dependencies)(didUpdate: EffectArg): Unit

    Effect is run when dependencies change.

  59. def useEffectAlways(didUpdate: EffectArg): Unit

    Effect is always run on render, which is probably too much.

  60. def useEffectMounting(didUpdate: EffectArg): Unit

    Effect is run at mount/unmount time with an implied [] per the react docs.

  61. def useEffectUnmounting(thunk: Function0[Unit]): Unit
  62. def useImperativeHandle[T, R <: Object](ref: MutableRef[T], thunk: () => R, dependencies: UndefOr[Dependencies]): Unit

    Expose imperative functions in R to refs.

    Expose imperative functions in R to refs.

    T

    Ref type

    R

    js object whose properties are functions. This is not enforced in the type.

  63. def useLayoutEffect(didUpdate: EffectArg, dependencies: UndefOr[Dependencies]): Unit

    Run before browser updates the screen.

    Run before browser updates the screen. Kinda a "sync" effect.

  64. def useMemo[T](dependencies: AllType*)(value: Function0[T]): T
  65. def useMemo[T](value: () => T): T
  66. def useMemoA[T](dependencies: Dependencies)(value: Function0[T]): T
  67. def useMemoMounting[T](value: () => T): T
  68. def useMutableSource[S, A](source: MutableSource[S], getSnapshot: Function1[S, A], subscribe: Function2[S, Function0[Unit], Function0[Unit]]): A

    subscribe 2nd arg is to be called whenever the value changes and is stable.

    subscribe 2nd arg is to be called whenever the value changes and is stable. Last is an unsubscribe for unmounting.

  69. def useReducer[S, A, I](reducer: (S, A) => S, initialArg: I, init: (I) => S): (S, Dispatch[A])
  70. def useReducer[S, A](reducer: (S, A) => S, initialState: S): (S, Dispatch[A])
  71. def useRef[T](initialValue: T): MutableRef[T]

    Do not include Null in your type parameter as it added to MutableRef.current automatically.

  72. def useState[T](initial: () => T): (T, Function1[Function1[T, T], Unit])

    Initial value is a "lazy".

    Initial value is a "lazy". Setter is an updater. Use this one or useReducer.

  73. def useStateDirect[T](initial: () => T): (T, Function1[T, Unit])

    Initial value is a "lazy".

    Initial value is a "lazy". Set new value directly. Don't use this.

  74. def useStateStrict[T](initial: T): (T, Function1[Function1[T, T], Unit])

    Initial value is strict.

    Initial value is strict. Setter is an updater.

  75. def useStateStrictDirect[T](initial: T): (T, Function1[T, Unit])

    Initial value is strict.

    Initial value is strict. Set new value directly. Don't use this.

  76. def useTransition(t: Int): (Function1[Function0[Unit], Unit], Boolean)
  77. def useTransition(config: TransitionConfig): (Function1[Function0[Unit], Unit], Boolean)
  78. val version: String
  79. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  80. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  81. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  82. object Fragment

    Create a React.fragment element.

  83. object StrictMode

    Strict element.

    Strict element. Wraps your root component typically.

  84. object Suspense

    Catch a thrown js.Promise from the child.

    Catch a thrown js.Promise from the child. Show fallback until the promise is resolved.

  85. object SuspenseList

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped