https://github.com/afeiship/use-force-update
React hook use-force-update.
https://github.com/afeiship/use-force-update
force-update hook react trigger
Last synced: about 1 month ago
JSON representation
React hook use-force-update.
- Host: GitHub
- URL: https://github.com/afeiship/use-force-update
- Owner: afeiship
- License: mit
- Created: 2021-07-06T10:15:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-07T00:48:16.000Z (almost 5 years ago)
- Last Synced: 2025-08-08T18:31:10.526Z (11 months ago)
- Topics: force-update, hook, react, trigger
- Language: JavaScript
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# use-force-update
> React hook use-force-update.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```shell
npm install -S @jswork/use-force-update
```
## usage
```js
import ReactDemokit from '@jswork/react-demokit';
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import useForceUpdate from '../src/main';
import './assets/style.scss';
const ForceComponent = () => {
const [count, setCount] = useState({ value: 0 });
const forceUpdate = useForceUpdate();
return (
{
console.log('update value use forceUdpate');
count.value = count.value + 1;
forceUpdate();
}}>
increase
{count.value}
{
console.log('set count use a new object.');
setCount({ value: count.value - 1 });
}}>
decrease
);
};
class App extends React.Component {
render() {
return (
);
}
}
ReactDOM.render(, document.getElementById('app'));
```
## documentation
- https://afeiship.github.io/use-force-update/
## license
Code released under [the MIT license](https://github.com/afeiship/use-force-update/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/use-force-update
[version-url]: https://npmjs.org/package/@jswork/use-force-update
[license-image]: https://img.shields.io/npm/l/@jswork/use-force-update
[license-url]: https://github.com/afeiship/use-force-update/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/use-force-update
[size-url]: https://github.com/afeiship/use-force-update/blob/master/dist/use-force-update.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/use-force-update
[download-url]: https://www.npmjs.com/package/@jswork/use-force-update