Skip to content

Commit bee8d5c

Browse files
authored
Update CALLBACK.md
1 parent d5521f1 commit bee8d5c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/CALLBACK.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,14 @@ Common Mistakes
296296
val grantPrivateAccess: CallbackTo[Boolean] =
297297
getToken.map(_ != null)
298298
```
299+
300+
* **() => Callback**
301+
302+
Callbacks are already repeatable, and do nothing when you create one.
303+
There's no need or benefit to adding `() =>`.
304+
305+
Just pass around `Callback` instances instead. If React never chooses to execute them, they'll never be executed.
306+
307+
But look, if for some reason you just really, really want to have a side-effect in the *construction* of the callback,
308+
then wrap the construction in `Callback.byName` and continue to pass around `Callback` instead of `() => Callback`.
309+

0 commit comments

Comments
 (0)