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.
- Alphabetic
- By Inheritance
- React
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- 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.
- def createContext[T](defaultValue: T): ReactContext[T]
- 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".
- def createElement[P <: Object](component: ReactType, props: P, children: ReactNode*): ReactElement
Create an element using the standard var args signature.
- 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.
- def createElement0(tag: ReactType, props: |[Object, Dynamic]): ReactElement
Create an element with props and 0 children.
- def createElement1(tag: ReactType, props: |[Object, Dynamic], child: ReactNode): ReactElement
Create an elemnt with 1 child only.
- def createElementN(tag: ReactType)(children: ReactNode*): ReactElement
Create an element without props but with children as a separate parameter.
- def createElementN(tag: ReactType, props: |[Object, Dynamic])(children: ReactNode*): ReactElement
Create an element with props and children.
- 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".
- def createMutableSource[S](source: Any, getVersion: Function0[Any]): MutableSource[S]
- def createRef[T](): ReactRef[T]
Create a
ReactRef
. - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- 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?
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def lazy(lazyComponent: DynamicImportThunk): ReactJSLazyComponent
- 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.
- def memo[P <: Object](fc: Function1[P, ReactNode]): Function1[P, ReactNode]
Memoize a function.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unsafeCreateElement(component: (Dynamic) => ReactNode, props: Dynamic): ReactElement
- 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.
- def useCallback[T](dependencies: AllType*)(callback: Function0[T]): Function0[T]
- def useCallback1[A1, T](dependencies: AllType*)(callback: Function1[A1, T]): Function1[A1, T]
- def useCallback1A[A1, T](dependencies: Dependencies)(callback: Function1[A1, T]): Function1[A1, T]
- def useCallback2[A1, A2, T](dependencies: AllType*)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- def useCallback2A[A1, A2, T](dependencies: Dependencies)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- def useCallback3[A1, A2, A3, T](dependencies: AllType*)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
- def useCallback3A[A1, A2, A3, T](dependencies: Dependencies)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
- def useCallback4[A1, A2, A3, A4, T](dependencies: AllType*)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
- def useCallback4A[A1, A2, A3, A4, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
- def useCallback5[A1, A2, A3, A4, A5, T](dependencies: AllType*)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
- def useCallback5[A1, A2, A3, A4, A5, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
- def useCallbackA[T](dependencies: |[Dependencies, Unit])(callback: Function0[T]): Function0[T]
- def useCallbackMounting[T](callback: Function0[T]): Function0[T]
- def useCallbackMounting1[A1, T](callback: Function1[A1, T]): Function1[A1, T]
- def useCallbackMounting2[A1, A2, T](callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- def useCallbackMounting3[A1, A2, A3, T](callback: Function3[A1, A2, A3, T]): Function3[A1, A2, A3, T]
- def useCallbackMounting4[A1, A2, A3, A4, T](callback: Function4[A1, A2, A3, A4, T]): Function4[A1, A2, A3, A4, T]
- def useCallbackMounting5[A1, A2, A3, A4, A5, T](callback: Function5[A1, A2, A3, A4, A5, T]): Function5[A1, A2, A3, A4, A5, T]
- def useContext[T](context: ReactContext[T]): T
- def useDebugValue[T](value: T, format: (T) => String): Unit
- def useDebugValue[T](value: T): Unit
- def useDeferredValue[T](value: T, t: Int): T
- 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.
- def useEffect(dependencies: AllType*)(didUpdate: EffectArg): Unit
Effect is run when dependencies change.
- def useEffectA(dependencies: Dependencies)(didUpdate: EffectArg): Unit
Effect is run when dependencies change.
- def useEffectAlways(didUpdate: EffectArg): Unit
Effect is always run on render, which is probably too much.
- def useEffectMounting(didUpdate: EffectArg): Unit
Effect is run at mount/unmount time with an implied
[]
per the react docs. - def useEffectUnmounting(thunk: Function0[Unit]): Unit
- 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.
- def useLayoutEffect(didUpdate: EffectArg, dependencies: UndefOr[Dependencies]): Unit
Run before browser updates the screen.
Run before browser updates the screen. Kinda a "sync" effect.
- def useMemo[T](dependencies: AllType*)(value: Function0[T]): T
- def useMemo[T](value: () => T): T
- def useMemoA[T](dependencies: Dependencies)(value: Function0[T]): T
- def useMemoMounting[T](value: () => T): T
- 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.
- def useReducer[S, A, I](reducer: (S, A) => S, initialArg: I, init: (I) => S): (S, Dispatch[A])
- def useReducer[S, A](reducer: (S, A) => S, initialState: S): (S, Dispatch[A])
- def useRef[T](initialValue: T): MutableRef[T]
Do not include
Null
in your type parameter as it added toMutableRef.current
automatically. - 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.
- 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.
- def useStateStrict[T](initial: T): (T, Function1[Function1[T, T], Unit])
Initial value is strict.
Initial value is strict. Setter is an updater.
- 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.
- def useTransition(t: Int): (Function1[Function0[Unit], Unit], Boolean)
- def useTransition(config: TransitionConfig): (Function1[Function0[Unit], Unit], Boolean)
- val version: String
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- object Fragment
Create a React.fragment element.
- object StrictMode
Strict element.
Strict element. Wraps your root component typically.
- 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.
- object SuspenseList