flagsmith-js-client icon indicating copy to clipboard operation
flagsmith-js-client copied to clipboard

fix: catch init error in useFlagsmith

Open Zaimwa9 opened this issue 3 months ago • 0 comments

Closes #347 Problem When initial fetching of flags failed using one of the lib react hook (500, 403), the promise rejection is unhandled, causing console errors and surfacing the error to the parent app.

Changes

  • Added .catch in react.tsx when calling init to prevent unhandled rejections
  • emit an event to update react hooks
  • Ensure flags default or disabled if not provided
  • Error captured in loadingState.error

Test

  • Added a test covering the case

Before fix: image

After fix: image

Zaimwa9 avatar Oct 30 '25 10:10 Zaimwa9