configcat / react-sdk

ConfigCat SDK for React. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
MIT License
12 stars 7 forks source link

Update ConfigCatHooks.tsx #34

Closed hakubo closed 9 months ago

hakubo commented 1 year ago

set loading to true when we are about to call getValueAsync

Describe the purpose of your pull request

Maybe there is a better way to do this.

Ideally we would get value immediately after user change, but since we are using useEffect here - it usually takes 2 re-renders to get updated value. Meaning there is no way from app perspective to know if we're getting stale value or not.

With setting loading to true - at least app can see that there is loading happening, but that probably introduces a 3 re-render...

in react-query - there are 2 flags for example isLoading when we have no data and have to load it and isFetching when we have data but we're loading new data - so user can decide if they want to use stale data or not.

Ideally though we should decrease number of re-renders IMO.

Related issues (only if applicable)

Provide links to issues relating to this pull request

Requirement checklist (only if applicable)

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

laliconfigcat commented 9 months ago

Hello @hakubo ,

I'm closing this pull request for now, but feel free to reopen it, if you made any progress with it.