CharlestonREM / MedsyPurchase

theme from themeforest
medsy-minimal-test-git-main.charlestonrem.vercel.app
0 stars 0 forks source link

(Possible) Infinite Loop caused by Context Provider(s) #4

Open CharlestonREM opened 3 years ago

CharlestonREM commented 3 years ago

Problem

An infinite loop (or infinite loops) seem to be occurring due to the unstable context value of one or multiple providers.

This project has 4 providers that I have created.

  1. The Stepper Provider
  2. The Available Products Provider
  3. The Calculator Provider
  4. The Modal Provider

Research & considering useMemo hook

All four of these providers employ React's useReducer hook. In a final note on useReducer in Hooks Api, there is a subheading labeled Bailing out of a dispatch

If you’re doing expensive calculations while rendering, you can optimize them with useMemo.

A question I don't currently have a clear answer to: what constitutes as an

expensive value

?

useMemo

CharlestonREM commented 3 years ago

similar issue with useReducer

https://github.com/facebook/react/issues/16537#issue-483790210

response

https://github.com/facebook/react/issues/16537#issuecomment-523771554

CharlestonREM commented 3 years ago

maybe the calculator provider &/or calculator component is causing the infinite loop...

CharlestonREM commented 3 years ago

is it vercel related? https://github.com/vercel/next.js/issues/6973

CharlestonREM commented 3 years ago

https://github.com/vercel/next.js/issues/6973#issuecomment-821500414

https://github.com/vercel/next.js/issues/6973#issuecomment-821508232