@frugalwizard/random-react-utils
v0.2.0
Published
Random React Utils
Downloads
1
Readme
README
What is this?
This is compilation of random utilities for building React apps.
Should I use this?
Currently it's not to be considered stable.
Use at your own discretion and don't rely on anything staying backward compatible.
What utilities are included here?
A wrapper for effects that use an
AbortSignal
.A wrapper for async effects.
A component that handles nesting multiple no args components.
A symbol/type to mark state as non-existent.
noop
An empty function. Useful when such a function is required and it being a stable value is preferable.
A helper for setting up listener to clicks that happen outside an element.
A symbol/type to mark state as pending.
A function that calls
preventDefault
on its first argument. Useful for some use cases with event handlers.A function to push an url/state into navigation history. Also triggers the corresponding
popstate
event.An
useState
alternative for boolean flags.Another
useState
alternative for boolean flags.A
useState
alternative for handling cursors over numerically indexed lists (e.g. pagination).A mutable function reference. Useful when you need to keep a callback for later without keeping it as part of the component state.
A hook for dynamically keeping track of one or more
Promises
and providing a flag that indicates whether there are pendingPromises
or not.Returns the current URL and causes the component to rerender when it changes. Useful to handle URL routing yourself.
Indicates whether the current viewport matches a media query and causes a rerender if the condition changes.
A hook for handling a mutable value. Useful for keeping track of data during the component lifecycle that does not need to be part of the component state.
A flag which indicates when the viewport is view resized.
A way for components to share state and/or prevent unnecessary rerenders and coupling between parent and child components.
An alternative to React's
useContext
.An
AbortSignal
that triggers when the component unmounts. Useful for async callbacks that need to be aborted when the component unmounts.