Skip to content

Commit

Permalink
fix: Update useForceUpdate.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
97vack authored Mar 14, 2024
1 parent d29e7c6 commit b1b3de2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/use/useForceUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import { useState } from 'react';

export default function useForceUpdate() {
const [, setState] = useState({});
const forceUpdate = () => {
setState({});
const forceUpdate = (delay: boolean = true) => {
if (delay) {
setTimeout(() => {
setState({});
});
} else {
setState({});
}
};
return forceUpdate;
}

0 comments on commit b1b3de2

Please sign in to comment.