@ptolemy2002/react-force-rerender
v2.0.0
Published
The main purpose of this library is to provide access to a hook that returns a function that forces a rerender upon being called. It uses setTimeout as a method to bypass the "Cannot update a component while rendering a different component" error (seems t
Readme
React Force Rerender
The main purpose of this library is to provide access to a hook that returns a function that forces a rerender upon being called. It uses setTimeout as a method to bypass the "Cannot update a component while rendering a different component" error (seems to be the easiest solution found at stackoverflow).
The hook is exported as default, so you can import in one of the following ways:
// ES6
import useForceRerender from '@ptolemy2002/react-force-rerender';
// CommonJS
const useForceRerender = require('@ptolemy2002/react-force-rerender');Functions
The following functions are available in the library:
useForceRerender
Description
This hook returns a function that forces a rerender upon being called. It uses setTimeout as a method to bypass the "Cannot update a component while rendering a different component" error.
Parameters
None
Returns
() => void - The function that forces a rerender.
Peer Dependencies
react^18.3.1react-dom^18.3.1
Commands
The following commands exist in the project:
npm run build- Builds the librarynpm run dev- Starts the development servernpm run lint- Lints the projectnpm run uninstall- Uninstalls all dependencies for the library and clears the cachenpm run reinstall- Uninstalls, clears the cache, and then reinstalls all dependencies for the librarynpm run release- Publishes the library to npm without changing the versionnpm run release-patch- Publishes the library to npm with a patch version bumpnpm run release-minor- Publishes the library to npm with a minor version bumpnpm run release-major- Publishes the library to npm with a major version bump
