API
connect
is a function taking an Eagle Eye context object and an optional selector map parameters; and returning a reusable connector function.
The connector function takes a client as a parameter and returns an HOC.
Any client using similar context object and selector map may be passed to this connector.
The HOC injects the context store to the client and handles all of the context usage requirements.
The injected store monitors changes in the underlying state slices referenced by the selector map.
A change in any of the referenced state slices automatically triggers an update of the related
store.data
property and a subsequent render of the client.Any prop name conflicts between the injected store properties and the client's own props are resolved in favor of the client's own props. Such a scenario may be remedied by renaming the conflicting key within the selector map.
createContext
is a zero-parameter function returning an Eagle Eye context object.
The returned object is the store-bearing context.
To access the context's store, pass the context as a
context
parameter to either the connect function or the useContext hook.UsageError
is the Error type reported for attempts to access this context's store outside of its Provider component tree.
useContext
is a hook taking an Eagle Eye context object and an optional selector map parameters; and returning the context store.
The injected store monitors changes in the underlying state slices referenced by the selector map.
A change in any of the referenced state slices automatically triggers an update of the related
store.data
property and a subsequent render of the client.The connect function is axiomatically the more conducive method for consuming this conetxt.
In certain user-specific cases, direct access to this hook may be preferrable.
In such cases, it is advisable to wrap the client in a
React.memo()
.