flagsmith-js-client
flagsmith-js-client copied to clipboard
fix: catch init error in useFlagsmith
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
.catchinreact.tsxwhen calling init to prevent unhandled rejections - emit an
eventto 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:
After fix: