1

In React we have latest new function called cache so what should be different between cache and useMemo hook in react

import {cache} from 'react';

1 Answer 1

3

In general, you should use cache in Server Components to memoize work that can be shared across components. cache is recommended for memoizing data fetches, unlike useMemo which should only be used for computations.

At this time, cache should only be used in Server Components and the cache will be invalidated across server requests.

Sign up to request clarification or add additional context in comments.

1 Comment

Cache can also be used to preload data react.dev/reference/react/cache#preload-data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.