mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
useForceUpdate: Return stable function (#86094)
This commit is contained in:
parent
23cd2d3e6f
commit
31879f1f5a
@ -1,7 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
|
||||
/** @internal */
|
||||
export function useForceUpdate() {
|
||||
const [_, setValue] = useState(0); // integer state
|
||||
return () => setValue((prevState) => prevState + 1); // update the state to force render
|
||||
return useCallback(() => setValue((prevState) => prevState + 1), []);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user