useSetupEffect
useSetupEffect(
effect,dependencies):void
A useLayoutEffect that runs on the room and on every page alike, and
receives a setup writer, open while the effect runs and again while its
cleanup does: what a logic component registers as it mounts, as a
plugin’s setup does, such as a weapon every player carries:
useSetupEffect((writer) => registerWeapon(writer, name, settings), []).
Its cleanup undoes what it registered, since StrictMode, a hot reload
and a change of dependencies each run the cleanup and then the effect
again. Inside a view it throws in development, naming the component,
and in a built game logs once and runs nothing.
On a page in a room it writes nothing the room streams, since the
room, which runs the same effect, writes that.
What only the room decides goes in useAuthorityEffect. As Unity’s
OnCreate runs on every world.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
effect |
(writer) => void | Disposer |
dependencies |
DependencyList |
Returns
Section titled “Returns”void