Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
¿Hay alguna manera de anular lo que hace useMemo para determinar si hay un cambio?

useMemo(() => expensiveFunction(), [deps]) vuelve a ejecutar la funcionCara cuando las deps han cambiado. Me preguntaba... ¿hay alguna forma de controlar cómo React comprobará si las deps han cambiado?

Me gustaría ver si puedo hacer una verificación isEqual "profunda" de las dependencias en lugar de una verificación superficial, como lo hice al usar useReducer para implementar useDeepState

 import isEqual from "lodash.isequal"; import { Dispatch, useReducer } from "react"; /** * This is similar to the `React.useState` function except it uses * [lodash.isEqual](https://lodash.com/docs/4.17.15#isEqual) to perform a * deep comparison of the values. * @param initialState initial state * @returns state, setter * @category React State */ export function useDeepState<S>(initialState: S | (() => S)): [S, Dispatch<S>] { function newStateIfNotEqual(state: S, newState: S) { return isEqual(state, newState) ? state : newState; } if (typeof initialState === "function") { return useReducer( newStateIfNotEqual, null as unknown as S, initialState as () => S ); } else { return useReducer( newStateIfNotEqual, initialState ); } }

https://github.com/trajano/react-hooks/blob/master/src/useStates/useDeepState.ts

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!