react
package react
A scala.js react facaded in the spirit of ReasonReact.
- Alphabetic
- By Inheritance
- react
- When
- React
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
Type Members
- trait AllInstances extends jshelpers.AllInstances with ValueConverters with ValueInstances
- trait AllSyntax extends ComponentSyntax with ValueSyntax with JsDynamicSyntax with JsObjectSyntax with JsAnySyntax with OrNullSyntax with ScalaMappedSyntax with OptionSyntax with JsUndefOrSyntax with MiscOrSyntax with JsRefSyntax with JSPromiseSyntax with ContextSyntax with OrSyntax with JSArraySyntax
- type AllType = |[|[|[|[|[|[|[|[|[|[|[|[Boolean, Byte], Short], Float], String], Double], Int], Object], Dictionary[_]], Symbol], Array[Any]], Null], Unit]
General purpose type that grabs AnyVal and some js types.
- trait Children extends Object
- Annotations
- @JSType() @native()
- trait ComponentSyntax extends AnyRef
- trait Concurrent extends Object
- Annotations
- @JSType() @native()
- trait ContextSyntax extends AnyRef
- trait DeferredValueConfig extends Object
- Annotations
- @JSType()
- type Dependencies = Array[AllType]
Hook dependencies data structure.
Hook dependencies data structure. Should this be scala.Any? The docs suggest otherwise.
- type Dispatch[A] = Function1[A, Unit]
A js dispatch function for side effects.
A js dispatch function for side effects. Used in useState.
- trait DynamicImport extends Object
Opaque type.
Opaque type.
- Annotations
- @JSType() @native()
- type DynamicImportThunk = Function0[Promise[DynamicImport]]
The type of
() => import("somecomponent")
which is used exclusively for the argument to React.lazy. - trait EffectArg extends Object
Magnet pattern to create a friendly arg converter for effect hooks.
Magnet pattern to create a friendly arg converter for effect hooks. As much as possible these need to be casts vs allocations.
- Annotations
- @JSType() @native()
- trait HasKey extends Object
Known to contain a key.
Known to contain a key.
- Annotations
- @JSType()
- trait HasStrKey extends Object
With key but key is known to be a String which is the common scenario.
With key but key is known to be a String which is the common scenario.
- Annotations
- @JSType()
- trait Hooks extends Object
- Annotations
- @JSType() @native()
- type ImportedJSComponent = |[|[ReactJSComponent, ReactJSFunctionComponent], ReactJSLazyComponent]
All the types of components that can be imported from JS.
All the types of components that can be imported from JS. These must be processed to be allowed to be used as Components in this facade. Keep in sync with
ReactType
. - final case class JsRefOps[T](v: ReactRef[T]) extends Product with Serializable
- trait JsRefSyntax extends AnyRef
- type KeyType = |[String, Int]
Very un-ergonomic, but this is what FB has.
- trait MaybeHasStrKey extends Object
Optional key but no ref.
Optional key but no ref. Key must be a string.
- Annotations
- @JSType()
- case class MemoizeLast[-T, +R](f: (T) => R, eq: (T, T) => Boolean = (a: T, b: T) => a == b) extends (T) => R with Product with Serializable
Memoize the last value only.
Memoize the last value only. Since its only 1 arg, use
yourfunc _ tupled
to tuple the arguments. Uses scala == for the test. js semantics for equality are very different. scala provids semantic equality unlike js. An optionaleq
can be used. In general, you will probably memoize js functions using the react hooks so may not need this memoization utility much.- See also
https://medium.com/musings-on-functional-programming/scala-optimizing-expensive-functions-with-memoization-c05b781ae826
- trait MutableRef[T] extends Object
For use with useRef() hook which is slightly different than the mutable Ref.
For use with useRef() hook which is slightly different than the mutable Ref.
current
is designed to be set directly or can be used on theref
attribute for a component. Since you can provide an initial value, if you wantnull
to be valid, either usenull
directly or model it explicitly asT|Null
to force client's to deal with the explict null value (otherwise they need to check for thenull
value directly).- Annotations
- @JSType()
- trait MutableSource[T] extends Object
Opaque type.
Opaque type.
- Annotations
- @JSType() @native()
- type PropsChildren = Array[ReactElement]
Children type.
- trait React extends AnyRef
Scala-side access to JSReact APIs.
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.
- trait ReactChildren extends ReactElement
- Annotations
- @JSType() @native()
- trait ReactClass extends Object
A js-object that is returned from create-react-class.
A js-object that is returned from create-react-class. In reactjs a react class is a js object created using the "class" construct. This should really be ReactJSComponent but we keep this slightly different for those who care about such things.
- Annotations
- @JSType() @native()
- type ReactComponentType = |[|[|[|[|[|[ReactClass, ReactJSComponent], ReactJSFunctionComponent], ReactJSLazyComponent], ScalaJSFunctionComponent], ScalaJSFunctionComponent1], ScalaJSFunctionComponent1WithRef]
Component type that can be used in HOCs.
- trait ReactContext[T] extends Object
React's context object contains the consumer and provider "components".
React's context object contains the consumer and provider "components".
- Annotations
- @JSType() @native()
- final class ReactContextOps2[T] extends AnyVal
Removing only the "r" on the end may be confusing...
- trait ReactDOMElement extends ReactElement
A standard HTML element that has been created using createElement.
A standard HTML element that has been created using createElement. Props are optional of course. We use this tag it to show that it came from the standard DOM components vs a custom one.
- Annotations
- @JSType() @native()
- trait ReactElement extends ReactNode
Output from
react.createElement
.Output from
react.createElement
. Subtype of ReactNode to indicate that the output came fromcreateElement
vs say, a string or number.- Annotations
- @JSType() @native()
- type ReactElementTuple[P <: Object] = (Function1[P, ReactNode], P)
A type for declaring an element using a tuple and an implicit conversion.
A type for declaring an element using a tuple and an implicit conversion. An implicit can pick this up and convert it to a react element.
- type ReactFC[P <: Object] = Function1[P, ReactNode]
A type used to drive type inference when declaring your component.
- type ReactFC0 = Function0[ReactNode]
A type used to drive type inference when declaring your component.
- trait ReactJS extends Object with Concurrent
- Annotations
- @JSType() @native()
- trait ReactJSComponent extends Object
This type is used only as a target for imported javascript authored components to "tag" a component type or created via other js-interop mechanisms such as redux integration.
This type is used only as a target for imported javascript authored components to "tag" a component type or created via other js-interop mechanisms such as redux integration. By using a separate type, you must use then scalajs-react's API to create an element. You can use this to annotate a js function react component as well e.g. () => ReactNode.
- Annotations
- @JSType() @native()
- trait ReactJSFunctionComponent extends Object
Import type target from js land that are functions and imported as such.
Import type target from js land that are functions and imported as such. May or may not make a difference to have this typed separately. You could also import it as a jsFunctionN object.
- Annotations
- @JSType() @native()
- trait ReactJSLazyComponent extends Object with ReactJSComponent
Not sure why I still have this.
Not sure why I still have this. Probably should avoid.
- Annotations
- @JSType() @native()
- trait ReactJSProps extends Object
Use this instead of ReactPropsJs.
Use this instead of ReactPropsJs. But! you should probably should be using
MaybeHasStrKey
- Annotations
- @JSType()
- trait ReactModule extends Object
The module "object" that you import when you use react.
The module "object" that you import when you use react.
- Annotations
- @JSType() @native()
- trait ReactNode extends Any
Something that can be rendered in reactjs.
Something that can be rendered in reactjs. react allows this to be quite flexible including strings, numbers, booleans in additon to classes or functions. Classes and functions are convered to a ReactNode by calling
createElement
on them however strings and numbers can be rendered directly.- Annotations
- @JSType() @native()
- trait ReactNodeEncoder[A] extends AnyRef
Encode a value to a ReactNode.
Encode a value to a ReactNode. This can only be used for values that are themselves directly renderable because if you want to create a ReactNode from a component, you must call
createElement
with some props, and this typeclass does not have props anywhere! - trait ReactPortal extends ReactElement
For creating a portal in react-dom.
For creating a portal in react-dom.
- Annotations
- @JSType() @native()
- trait ReactPropTypes extends Object
- Annotations
- @JSType() @native()
- trait ReactRef[T] extends Object
Object returned from
createRef()
.Object returned from
createRef()
. It's typically either js component or a DOM element, both of which are js.Objects. You only use this type with theReact.createRef()
machinery. Use this instead of a string or ref callback. Introduced in 16.3.useRef
uses a slightly different flavor ofcurrent
.- Annotations
- @JSType() @native()
- To do
Validate a null value is present if the ref is never set. typescript says so.
- type ReactType = |[|[|[|[|[|[|[ReactClass, String], ReactJSComponent], ReactJSFunctionComponent], ReactJSLazyComponent], ScalaJSFunctionComponent], ScalaJSFunctionComponent1], ScalaJSFunctionComponent1WithRef]
Something that can be used in
ReactJS.createElement()
.Something that can be used in
ReactJS.createElement()
. Given an object of this type, you must callcreateElement
on it to create the element with optional props and children. If a parent is in a component, you use this type to represent it. - type RectFCWithRef[P <: Object, T <: Any] = Function2[P, ReactRef[T], ReactNode]
A component that takes a ref as the second argument.
- type Ref[E] = |[|[RefCb[E], ReactRef[E]], MutableRef[E]]
Combine the callback and the createRef models.
Combine the callback and the createRef models. Also include the newer hooks model.
- type RefCb[E] = Function1[|[E, Null], Unit]
Callback for react ref with settable E.
- trait Requireable[T <: Any] extends Object
- Annotations
- @JSType() @native()
- type ScalaJSFunctionComponent = Function0[ReactNode]
Pure JS functions defined in scala are also components.
- type ScalaJSFunctionComponent1 = Function1[_ <: Object, ReactNode]
Pure JS functions defined in scala are also components.
- type ScalaJSFunctionComponent1WithRef = Function2[_ <: Object, _ <: Any, ReactNode]
- trait TransitionConfig extends Object
- Annotations
- @JSType()
- case class UseMutableSource[S, A]() extends Product with Serializable
Instantiate this to sync types needed for both funcs.
- trait ValueConverters extends AnyRef
Mostly obvious converters so you can have a variety of children types and have them convert to ReactNodes as needed.
Mostly obvious converters so you can have a variety of children types and have them convert to ReactNodes as needed.
Watch out for values that need to pass through 2 implicits since double implicit resolution is not supported by scala. So you may think that these conversions should apply but an
UndefOr
wrapper on the target type means either you need to use js.defined first and then these implicit conversions will apply automatically or you should use.toNode
to convert the ReactNode value then let the general implicit create anUndefOr[T]
. Just be mindful of implicit conversion rules in scala.- To do
Restructure as a typeclass using an "encoding" pattern, see the trait above :-).
- trait ValueInstances extends AnyRef
- final case class ValueOps[T](v: T) extends AnyVal with Product with Serializable
Convert any scala object to a ReactNode via
blah.toNode
. - trait ValueSyntax extends AnyRef
Enable
value.toNode
syntax.Enable
value.toNode
syntax.ValueConverters
enable direct conversion to ReactNode if you want to avoid the syntax and have magic. - class WeakMap extends Object
- Annotations
- @JSType() @native() @JSGlobal()
- trait When extends AnyRef
Conditional rendering support.
Conditional rendering support. Uses by-name parameters to delay creating a react node if the condition idicates not to render.
- macro class deriveClassNames extends Annotation with StaticAnnotation
Projection of a Styles object to a ClassNames trait.
Projection of a Styles object to a ClassNames trait. This is specific to fabric styling but essentially ignores the type anyway so it could be used elsewhere. No check is performed to make sure you are annotating a Styles object. A styles object has only var members with types
js.UndefOr[IStyle]
and initial valuejs.undefined
. The macro does not search superclasses (yet).- Annotations
- @compileTimeOnly("Enable macros -Ymacro-annotations (2.13+) to expand macro annotation")
- macro class deriveForwardingTrait extends Annotation with StaticAnnotation
"Exports" all defs and val/vars from a source object to another trait by creating static forwarders in the annotated trait.
"Exports" all defs and val/vars from a source object to another trait by creating static forwarders in the annotated trait. This allows you to proxy methods imported from a js module into any trait easily. Only vals (or readers for vars) and defs are exported from the source.
NOT FULLY TESTED YET!
- Annotations
- @compileTimeOnly("Enable macros -Ymacro-annotations (2.13+) to expand macro annotation")
- macro class jsenrich extends Annotation with StaticAnnotation
Build/enhance companion object with various convenience methods.
Build/enhance companion object with various convenience methods.
Convenience methods include:
apply
method for properties in the immediate js.Object trait. This will overwrite any existing apply method.- Extensions for changing individual properties:
aTrait.withYourPropertyName("blah")
. - Extension
combineWith(that)
to shallow combine two objects withthat
taking precedence. - Extension
.duplicate
that shallow clones the object usingjs.Object.assign
.
These methods adds/creates new companion object with methods and implicit classes.
WARNING: Does not handle trait parameters yet.
- Annotations
- @compileTimeOnly("Enable macros -Ymacro-annotations (2.13+) to expand macro annotation")
Deprecated Type Members
- type ReactClassInternal = ReactClass
Alias for internal use.
Alias for internal use.
- Deprecated
- trait ReactPropsJs extends Object
Use these to mix into your traits to ensure you have a a key and ref to set.
Use these to mix into your traits to ensure you have a a key and ref to set. For example, add this to a Props class so that you can specify a key when you create it. These are not special or used for tags, you can not use this trait and just define the key and/or ref in your Props trait directly.
- Annotations
- @JSType() @deprecated
- Deprecated
(Since version 0.1.0) Use ReactJSProps
Value Members
- def arrayToElement[T <: ReactNode](arr: Array[T]): ReactNode
Convenience.
Convenience. Use implicits for syntax-based conversion.
- def callbackAsRef[E](f: (|[E, Null]) => Unit): Ref[E]
- 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.
- Definition Classes
- React
- def copy[T <: Object](obj: |[Dynamic, Object]): T
Shallow copy.
Shallow copy. Should we call Object.assign directly? Faster?
- def createContext[T](defaultValue: T): ReactContext[T]
- Definition Classes
- React
- 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".
- Definition Classes
- React
- def createElement[P <: Object](component: ReactType, props: P, children: ReactNode*): ReactElement
Create an element using the standard var args signature.
Create an element using the standard var args signature.
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def createElement0(tag: ReactType, props: |[Object, Dynamic]): ReactElement
Create an element with props and 0 children.
Create an element with props and 0 children.
- Definition Classes
- React
- def createElement1(tag: ReactType, props: |[Object, Dynamic], child: ReactNode): ReactElement
Create an elemnt with 1 child only.
Create an elemnt with 1 child only.
- Definition Classes
- React
- def createElementN(tag: ReactType)(children: ReactNode*): ReactElement
Create an element without props but with children as a separate parameter.
Create an element without props but with children as a separate parameter.
- Definition Classes
- React
- def createElementN(tag: ReactType, props: |[Object, Dynamic])(children: ReactNode*): ReactElement
Create an element with props and children.
Create an element with props and children.
- Definition Classes
- React
- 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".
- Definition Classes
- React
- def createMutableSource[S](source: Any, getVersion: Function0[Any]): MutableSource[S]
- Definition Classes
- React
- def createRef[T](): ReactRef[T]
Create a
ReactRef
.Create a
ReactRef
.- Definition Classes
- React
- def deps(values: AllType*): Dependencies
Create a dependencies array.
Create a dependencies array. With on args, its a zero-length array.
- def emptyArray[T]: Array[T]
Empty array.
Empty array. Freshly allocated!
- def emptyChildren: Array[ReactNode]
Allocate an empty child array.
Allocate an empty child array. It's not shared like
emptyChildrenVal
- val emptyChildrenVal: Array[ReactNode]
Empty children value but non-empty array.
Empty children value but non-empty array. Be careful as someone could mutate this global instance on you.
- val emptyDependencies: Dependencies
Empty array which is different than undefinedDependencies.
Empty array which is different than undefinedDependencies. Typically indicates mount/unmount hook processing.
- 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.
- Definition Classes
- React
- Annotations
- @inline()
- To do
Seems like this is an expensive call. Can we do better?
- def iterableToElement[T <: ReactNode](s: Iterable[T]): ReactNode
Convenience.
Convenience. Use implicits for automatic conversion.
- def jsEqual(a: Any, b: Any): Boolean
Test equaliy with two js objects.
Test equaliy with two js objects. Standard == in scala.js on 2 js objects (e.g. non-native traits) will not test in the same way that standard scala tests equality. Do not use this with react components (js objects) because react component objects may have circular data structures.
You may want to look at some standard js equality libraries--there are many and are opimized in various ways. See https://github.com/FormidableLabs/react-fast-compare/blob/master/index.js in particular. This code is from https://stackoverflow.com/questions/38126349/how-to-deeply-compare-two-js-like-objects-in-scala-js.
- def jsdef[A](a: A): UndefOr[A]
Shorted version of
js.defined(blah)
Shorted version of
js.defined(blah)
- Annotations
- @inline()
- val jsundef: UndefOr[Nothing]
Short version of
js.undefined
. - def lazy(lazyComponent: DynamicImportThunk): ReactJSLazyComponent
- Definition Classes
- React
- 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.
Memoize with a function and a comparator.
- Definition Classes
- React
- def memo[P <: Object](fc: Function1[P, ReactNode]): Function1[P, ReactNode]
Memoize a function.
Memoize a function.
- Definition Classes
- React
- def memoWith[P <: Object](compare: (UndefOr[P], UndefOr[P]) => Boolean)(f: (P) => ReactNode): ReactFC[P]
Memo a function component.
- def memoWith[P <: Object](f: (P) => ReactNode): ReactFC[P]
Memo a function component.
- def memoWith[P <: Object](compare: Function2[UndefOr[P], UndefOr[P], Boolean])(f: ReactFC[P]): ReactFC[P]
Memo a function component.
- def memoWith[P <: Object](f: ReactFC[P]): ReactFC[P]
Memo a function component.
- def merge[T <: Object](objs: |[|[|[UndefOr[Object], Dynamic], Object], Null]*): T
Shallow merge objects into a new object and cast.
Shallow merge objects into a new object and cast. Useful when merging props with data- attributes or component properties together. Last value wins. A syntax version of this function is available on js objects called
combine
. Creates and returns new object. Note, should we just call js.Object.assign here? - def mergeJSObjects(objs: Dynamic*): Dynamic
Merge js.Dynamics into a fresh object.
Merge js.Dynamics into a fresh object. You should really use merge. https://stackoverflow.com/questions/36561209/is-it-possible-to-combine-two-js-dynamic-objects
- val noChildren: PropsChildren
No children value.
- val noCleanUp: () => Unit
Noop for effect callback.
- def noProps[T <: Object](): T
Type inferring empty js object.
Type inferring empty js object. A new object is created with each call.
- val noPropsVal: Object
Constant val of a single, empty js.Object.
Constant val of a single, empty js.Object. Use carefully since js allows mutation and this will be a shared instance. Prefer
noProps()
. - val nullDate: Date
Type inference helper.
- val nullDouble: Double
Type inference helper.
- val nullElement: ReactElement
Return a "render nothing" element.
Return a "render nothing" element. React ignores nulls during rendering.
- val nullFloat: Float
Type inference helper.
- val nullInt: Int
Type inference helper.
- val nullJSDate: Date
Type inference helper.
- val nullJSObject: Object
Type inference helper.
- val nullLong: Long
Type inference helper.
- val nullNode: ReactNode
null element, which does not render, cast to a ReactNode for better type inference.
- val nullString: String
Type inference hepler.
- def refCB[E](f: (|[E, Null]) => Unit): Ref[E]
Make Ref[E] from callback.
Make Ref[E] from callback. See syntax for dealing with E|Null.
- def refCallback[E](f: (|[E, Null]) => Unit): RefCb[E]
Make a callback.
Make a callback. You don't need this but helps with type inference. There is some dedicated syntax support for
E|Null
handling. - def refToJs[T](ref: ReactRef[T]): Dynamic
Turn a ReactRef to a js.Dynamic so you can call "component" methods directly.
Turn a ReactRef to a js.Dynamic so you can call "component" methods directly. Most notably "select", "value" or "focus()". I don't think this is right...
- def stringToElement(s: String): ReactNode
String to react node.
String to react node. Use implicits for automatic conversion and avoid calling this function.
- def toSafeOption[T <: Any](t: Any): Option[T]
Return None if undefined or null -> None, otherwise return a Some.
Return None if undefined or null -> None, otherwise return a Some. Syntax support makes this easier so you don't have to use this function.
- val undefinedDependencies: UndefOr[Dependencies]
Undefined array typically indicates per render hook computation.
- def unsafeCreateElement(component: (Dynamic) => ReactNode, props: Dynamic): ReactElement
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def unsafeDeps(values: Any*): Dependencies
Escape hatch.
Escape hatch. Create a dependencies array from *any* list of scala objects. Make sure you think about each value type in the list of dependencies. Use this inference helper to remind you to think about the types and scala-js interop.
- def useCallback[T](dependencies: AllType*)(callback: Function0[T]): Function0[T]
- Definition Classes
- React
- def useCallback1[A1, T](dependencies: AllType*)(callback: Function1[A1, T]): Function1[A1, T]
- Definition Classes
- React
- def useCallback1A[A1, T](dependencies: Dependencies)(callback: Function1[A1, T]): Function1[A1, T]
- Definition Classes
- React
- def useCallback2[A1, A2, T](dependencies: AllType*)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- Definition Classes
- React
- def useCallback2A[A1, A2, T](dependencies: Dependencies)(callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- Definition Classes
- React
- def useCallback3[A1, A2, A3, T](dependencies: AllType*)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
- Definition Classes
- React
- def useCallback3A[A1, A2, A3, T](dependencies: Dependencies)(callback: (A1, A2, A3) => T): Function3[A1, A2, A3, T]
- Definition Classes
- React
- def useCallback4[A1, A2, A3, A4, T](dependencies: AllType*)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
- Definition Classes
- React
- def useCallback4A[A1, A2, A3, A4, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4) => T): Function4[A1, A2, A3, A4, T]
- Definition Classes
- React
- def useCallback5[A1, A2, A3, A4, A5, T](dependencies: AllType*)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
- Definition Classes
- React
- def useCallback5[A1, A2, A3, A4, A5, T](dependencies: Dependencies)(callback: (A1, A2, A3, A4, A5) => T): Function5[A1, A2, A3, A4, A5, T]
- Definition Classes
- React
- def useCallbackA[T](dependencies: |[Dependencies, Unit])(callback: Function0[T]): Function0[T]
- Definition Classes
- React
- def useCallbackMounting[T](callback: Function0[T]): Function0[T]
- Definition Classes
- React
- def useCallbackMounting1[A1, T](callback: Function1[A1, T]): Function1[A1, T]
- Definition Classes
- React
- def useCallbackMounting2[A1, A2, T](callback: Function2[A1, A2, T]): Function2[A1, A2, T]
- Definition Classes
- React
- def useCallbackMounting3[A1, A2, A3, T](callback: Function3[A1, A2, A3, T]): Function3[A1, A2, A3, T]
- Definition Classes
- React
- def useCallbackMounting4[A1, A2, A3, A4, T](callback: Function4[A1, A2, A3, A4, T]): Function4[A1, A2, A3, A4, T]
- Definition Classes
- React
- def useCallbackMounting5[A1, A2, A3, A4, A5, T](callback: Function5[A1, A2, A3, A4, A5, T]): Function5[A1, A2, A3, A4, A5, T]
- Definition Classes
- React
- def useContext[T](context: ReactContext[T]): T
- Definition Classes
- React
- def useDebugValue[T](value: T, format: (T) => String): Unit
- Definition Classes
- React
- def useDebugValue[T](value: T): Unit
- Definition Classes
- React
- def useDeferredValue[T](value: T, t: Int): T
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def useEffect(dependencies: AllType*)(didUpdate: EffectArg): Unit
Effect is run when dependencies change.
Effect is run when dependencies change.
- Definition Classes
- React
- def useEffectA(dependencies: Dependencies)(didUpdate: EffectArg): Unit
Effect is run when dependencies change.
Effect is run when dependencies change.
- Definition Classes
- React
- def useEffectAlways(didUpdate: EffectArg): Unit
Effect is always run on render, which is probably too much.
Effect is always run on render, which is probably too much.
- Definition Classes
- React
- def useEffectMounting(didUpdate: EffectArg): Unit
Effect is run at mount/unmount time with an implied
[]
per the react docs.Effect is run at mount/unmount time with an implied
[]
per the react docs.- Definition Classes
- React
- def useEffectUnmounting(thunk: Function0[Unit]): Unit
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def useLayoutEffect(didUpdate: EffectArg, dependencies: UndefOr[Dependencies]): Unit
Run before browser updates the screen.
Run before browser updates the screen. Kinda a "sync" effect.
- Definition Classes
- React
- def useMemo[T](dependencies: AllType*)(value: Function0[T]): T
- Definition Classes
- React
- def useMemo[T](value: () => T): T
- Definition Classes
- React
- def useMemoA[T](dependencies: Dependencies)(value: Function0[T]): T
- Definition Classes
- React
- def useMemoMounting[T](value: () => T): T
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def useReducer[S, A, I](reducer: (S, A) => S, initialArg: I, init: (I) => S): (S, Dispatch[A])
- Definition Classes
- React
- def useReducer[S, A](reducer: (S, A) => S, initialState: S): (S, Dispatch[A])
- Definition Classes
- React
- def useRef[T](initialValue: T): MutableRef[T]
Do not include
Null
in your type parameter as it added toMutableRef.current
automatically.Do not include
Null
in your type parameter as it added toMutableRef.current
automatically.- Definition Classes
- React
- 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.
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def useStateStrict[T](initial: T): (T, Function1[Function1[T, T], Unit])
Initial value is strict.
Initial value is strict. Setter is an updater.
- Definition Classes
- React
- 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.
- Definition Classes
- React
- def useTransition(t: Int): (Function1[Function0[Unit], Unit], Boolean)
- Definition Classes
- React
- def useTransition(config: TransitionConfig): (Function1[Function0[Unit], Unit], Boolean)
- Definition Classes
- React
- val version: String
- Definition Classes
- React
- def when[T](cond: UndefOr[T])(render: => ReactNode): ReactNode
- Definition Classes
- When
- def when(cond: Boolean)(render: => ReactNode): ReactNode
Render something or return a null element.
Render something or return a null element. Render is by name. Could just use fold.
- Definition Classes
- When
- def when[T <: Boolean](cond: Option[T])(render: => ReactNode)(implicit ev: =:=[T, Boolean]): ReactNode
Render something or return a null element.
Render something or return a null element. Render is by name. Could just use fold.
- Definition Classes
- When
- def when[T <: Boolean](cond: UndefOr[T])(render: => ReactNode)(implicit ev: =:=[T, Boolean]): ReactNode
Render something or return a null element.
Render something or return a null element. Render is by name. Could just use fold.
- Definition Classes
- When
- def whenNot[T](cond: UndefOr[T])(render: => ReactNode): ReactNode
- Definition Classes
- When
- def whenNot[T <: Boolean](cond: Option[T])(render: => ReactNode)(implicit ev: =:=[T, Boolean]): ReactNode
Render something if not cond or return a null element.
Render something if not cond or return a null element. Render is by name. Could also use fold.
- Definition Classes
- When
- def whenNot[T <: Boolean](cond: UndefOr[T])(render: => ReactNode)(implicit ev: =:=[T, Boolean]): ReactNode
Render something if not cond or return a null element.
Render something if not cond or return a null element. Render is by name. Could also use fold.
- Definition Classes
- When
- def whenNot(cond: Boolean)(render: => ReactNode): ReactNode
Render something if notcond or return a null element.
Render something if notcond or return a null element. Render is by name. Could also use fold.
- Definition Classes
- When
- def withKey[T <: Object](element: T, key: String): ReactElement
Add a key.
Add a key. Mutates input object directly because hey, this is javascript! This is definitely not correct. DO NOT USE!
- case object BuildInfo extends Product with Serializable
This object was generated by sbt-buildinfo.
- object EffectArg
Implicit conversions that are very careful on the return value.
Implicit conversions that are very careful on the return value. If the return value is a parameterless function, it is assumed to be the reactjs "after-effect" callback. Otherwise, the return value is discarded.
- object MemoizeLast extends Serializable
- object PropTypes extends Object with ReactPropTypes
- Annotations
- @native() @JSImport("prop-types", JSImport.Namespace)
- object Fragment
Create a React.fragment element.
Create a React.fragment element.
- Definition Classes
- React
- object StrictMode
Strict element.
Strict element. Wraps your root component typically.
- Definition Classes
- React
- 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.
- Definition Classes
- React
- object SuspenseList
- Definition Classes
- React
- object ReactNodeEncoder
- object ReactPublic extends Object with ReactModule
A publically accessible react namespace import for those interop scenarios where you need this.
A publically accessible react namespace import for those interop scenarios where you need this. There are no scala visible methods, etc.
- Annotations
- @native() @JSImport("react", JSImport.Namespace)
- object createClass
- object implicits extends AllSyntax with AllInstances
- object instances extends Instances
Instances is the wrong concept here as these are not typeclass instances--but close enough as they are not syntax extensions "'element' converters" would be better similiar to
JSConverters
in scala.js. - object syntax