You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`Reusability.byRefOr_==` uses reference equality and if different, tries universal equality.
63
64
*`Reusability.caseClass` for case classes of your own.
64
65
*`Reusability.caseClassDebug` as above, but shows you the code that the macro generates.
65
66
*`Reusability.by(A => B)` to use a subset (`B`) of the subject data (`A`).
66
67
*`Reusability.fn((A, B) => Boolean)` to hand-write custom logic.
67
-
*`Reusability.byEqual` uses a Scalaz `Equal` typeclass.
68
-
*`Reusability.byRefOrEqual` uses reference equality and if different, tries using a Scalaz `Equal` typeclass.
69
68
*`Reusability.byIterator` uses an `Iterable`'s iterator to check each element in order.
70
69
*`Reusability.indexedSeq` uses `.length` and `.apply(index)` to check each element in order.
70
+
*`Reusability.{double,float}` exist and require a tolerance to be specified.
71
71
*`Reusability.{always,never,const(bool)}` are available too.
72
72
73
+
If you're using the Scalaz module, you also gain:
74
+
*`Reusability.byEqual` uses a Scalaz `Equal` typeclass.
75
+
*`Reusability.byRefOrEqual` uses reference equality and if different, tries using a Scalaz `Equal` typeclass.
76
+
77
+
73
78
#### Example
74
79
The following component will only re-render when one of the following change:
75
80
*`props.name`
@@ -84,8 +89,7 @@ The following component will only re-render when one of the following change:
84
89
implicitvalpropsReuse=Reusability.caseClass[Props] // ← check all fields
85
90
86
91
valcomponent=ReactComponentB[Props]("Demo")
87
-
.stateless
88
-
.render((p, _) =>
92
+
.render_P(p =>
89
93
<.div(
90
94
<.p("Name: ", p.name),
91
95
<.p("Age: ", p.age.fold("Unknown")(_.toString)),
@@ -136,46 +140,45 @@ provide no means of determining whether a component can safely skip its update.
136
140
In this example `personEditor` will only rerender if `props.name` changes, or the curried `PersonId` in its `props.update` function changes (which it won't - observable from the code).
@@ -431,10 +429,20 @@ Create a non-derivative `Px` using one of these:
431
429
}
432
430
```
433
431
434
-
4. `Px.const(A)` & `Px.lazyConst(=> A)` -A constant value.
432
+
4. `Px.bs($).{props,state}{A,M}` -A value extracts from a component's backend's props or state.
433
+
434
+
The `A` suffix denotes "Auto refresh", meaning that the function will be called every time the value is requested, and the value updated if necessary.<br>
435
+
The `M` suffix denotes "Manual refresh", meaning you must call `.refresh` yourself to check for updates.
436
+
437
+
5. `Px.const(A)` & `Px.lazyConst(=> A)` -A constant value.
435
438
436
439
These `Px`s do not have the ability to change.
437
440
441
+
6. `Px.cb{A,M}(CallbackTo[A])` -A value which is the result of running a callback.
442
+
443
+
The `A` suffix denotes "Auto refresh", meaning that the function will be called every time the value is requested, and the value updated if necessary.<br>
444
+
The `M` suffix denotes "Manual refresh", meaning you must call `.refresh` yourself to check for updates.
445
+
438
446
439
447
####Derivative instances
440
448
Derivative `Px`s are created by:
@@ -445,8 +453,8 @@ Derivative `Px`s are created by:
Once you have a `RouterConfig`, you can call `.renderWith` on it to supply your own render function that will be invokved each time a route is rendered. It takes a function in the shape: `(RouterCtl[Page], Resolution[Page]) => ReactElement` where a `Resolution` is:
417
+
Once you have a `RouterConfig`, you can call `.renderWith` on it to supply your own render function that will be invoked each time a route is rendered. It takes a function in the shape: `(RouterCtl[Page], Resolution[Page]) => ReactElement` where a `Resolution` is:
420
418
421
419
```scala
422
420
/**
@@ -440,26 +438,24 @@ Out-of-the-box, the default action is to scroll the window to the top.
440
438
You can *add* your own actions by calling `.onPostRender` on your `RouterConfig` instance.
441
439
You can *set* the entire callback (i.e. override instead of add) using `.setPostRender`.
442
440
443
-
Both `.onPostRender` and `.setPostRender` take a single arg: `(Option[Page], Page) => IO[Unit]`.
441
+
Both `.onPostRender` and `.setPostRender` take a single arg: `(Option[Page], Page) => Callback`.
444
442
The function is provided the previously-rendered page (or `None` when a router renders its first page),
0 commit comments