Open pastelmind opened 1 year ago
This PR adds two hooks useLatestRef() and useLayoutLatestRef() as described in https://github.com/streamich/react-use/issues/2328#issuecomment-1633958158. They are similar to useLatest(), but avoid updating the ref directly during render, which is deemed unsafe by the React team..
useLatestRef()
useLayoutLatestRef()
useLatest()
This PR also marks useLatest() as @deprecated and recommend useLatestRef() as an alternative.
@deprecated
yarn test
yarn lint
yarn lint:fix
yarn lint:types
Nice PR!
Really hope this is merged. useLatest is not safe.
Is there any progress?
Description
This PR adds two hooks
useLatestRef()
anduseLayoutLatestRef()
as described in https://github.com/streamich/react-use/issues/2328#issuecomment-1633958158. They are similar touseLatest()
, but avoid updating the ref directly during render, which is deemed unsafe by the React team..This PR also marks
useLatest()
as@deprecated
and recommenduseLatestRef()
as an alternative.Type of change
Checklist
yarn test
)yarn lint
). Fix it withyarn lint:fix
in case of failure.yarn lint:types
).