0.2.5 • Published 4 years ago

@snappmarket/use-force-update v0.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

useForceUpdate

👿 force update component

version downloads PRs Welcome MIT License

Watch on GitHub Star on GitHub

get started

We provide two way of using this package single or multi :

npm i @snappmarket/use-force-update
OR
npm i @snappmarket/hooks

usage

import useForceUpdate from '@snappmarket/use-force-update';
// or 
// import { useForceUpdate } from '@snappmarket/hooks';


const MyComponenet = props => {
  const forceUpdate = useForceUpdate(null);

  const handleSomeThing = () => {
    // do some thing
    forceUpdate();
  };

  return (<div>meow 🐱‍</div>)
};

source code

import { useState, useCallback } from 'react';

/**
 * Force component re-render
 * @returns {Function}
 */
export default function useForceUpdate() {
  const [, setTick] = useState(0);
  return useCallback(() => {
    setTick(tick => tick + 1);
  }, []);
}
0.2.5

4 years ago

0.2.3

4 years ago

0.2.1-alpha.0

4 years ago

0.1.24

4 years ago

0.1.22

4 years ago

0.1.21

4 years ago

0.1.20

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.13

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago