useGrainAnalytics() returns the GrainAnalytics client that GrainProvider holds. Use it for
every client method that has no hook of its own: identification, user properties, template events,
flush, and configuration preload.
Signature
GrainProvider is above the component. Read
GrainProvider.
The returned reference is the client of the provider. It changes only when the provider receives
a new client prop. It is safe in a dependency array.
Client methods for components
For events and configuration values, prefer the hooks.useTrack sends an event, useConfig and
useAllConfigs read values and re-render on change. The client methods below have no hook.
The full method list is in Core methods.
Identify after login
Preload configuration values
preloadConfig fills the cache. After it resolves, useConfig in a child shows the fetched value
on its first render.
Do not destroy the client
A provider-managed client is destroyed when the provider unmounts. Do not calldestroy() from a
component. After destroy(), every hook under the same provider calls a dead client.