Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useDeepCompareMemo hook #871

Closed
fengkx opened this issue Jul 12, 2022 · 2 comments
Closed

useDeepCompareMemo hook #871

fengkx opened this issue Jul 12, 2022 · 2 comments

Comments

@fengkx
Copy link
Contributor

fengkx commented Jul 12, 2022

New Features

useDeepCompareMemo hook

What is the new or updated feature that you are suggesting?

A deep compare version of useMemo

Why should this feature be included?

To memo a value with deep compare

import { useDeepCompareEffect } from '@react-hookz/web'
import { useState } from 'react'

export function useDeepCompareMemo<T> (
  factory: () => T,
  deps: React.DependencyList
) {
  const [state, setState] = useState(factory)
  useDeepCompareEffect(() => {
    setState(() => factory())
  }, deps)
  return state
}

Here is a poc impl

@ArttuOll
Copy link
Contributor

I'm starting to work on this.

ArttuOll added a commit that referenced this issue Oct 23, 2022
Implement useDeepCompareMemo by combining useCustomCompareMemo and the isEqual function from
react-hookz/deep-equal.

Closes #871
github-actions bot pushed a commit that referenced this issue Oct 23, 2022
# [16.1.0](v16.0.1...v16.1.0) (2022-10-23)

### Features

* **useDeepCompareMemo:** Implement useDeepCompareMemo ([#979](#979)) ([532cc41](532cc41)), closes [#871](#871)
@xobotyi
Copy link
Contributor

xobotyi commented Oct 23, 2022

🎉 This issue has been resolved in version 16.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants