Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Sep 29, 2025

The setState function is effectively asynchronous, multiple setState methods may be called in a single cycle before this.state is updated.

So if there were multiple dispatches of changes within a single batch, then some of the updates could be missed.

The way to handle this in react is to use the previous state provided using the method version of setState. The operations will be done sequentially with each having the correct view of the previous state.

@kinyoklion kinyoklion force-pushed the rlamb/SDK-1442/unproxied-flag-state-management branch from 7025ddb to 1e60c36 Compare September 29, 2025 20:57
const reactOptions = this.getReactOptions();
const updates = getFlattenedFlagsFromChangeset(changes, targetFlags);
const unproxiedFlags = {
...this.state.unproxiedFlags,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setState function is effectively asynchronous, multiple setState methods may be called in a single cycle before this.state is updated.

So if there were multiple dispatches of changes within a single batch, then some of the updates would be missed.

The way to handle this in react is to use the previous state provided using the method version of setState. The operations will be done sequentially with each having the correct view of the previous state.

@kinyoklion kinyoklion marked this pull request as ready for review September 29, 2025 21:29
@kinyoklion kinyoklion requested a review from a team as a code owner September 29, 2025 21:29
@kinyoklion kinyoklion merged commit 8d46bbd into main Sep 30, 2025
2 checks passed
@kinyoklion kinyoklion deleted the rlamb/SDK-1442/unproxied-flag-state-management branch September 30, 2025 16:10
kinyoklion pushed a commit that referenced this pull request Sep 30, 2025
🤖 I have created a release *beep* *boop*
---


##
[3.9.0](launchdarkly-react-client-sdk-v3.8.1...launchdarkly-react-client-sdk-v3.9.0)
(2025-09-30)


### Features

* Add experimental debug override functionality.
([63dd495](63dd495))
* Add experimental debug override functionality.
([4c4f3a3](4c4f3a3))
* Add experimental debug override functionality.
([#362](#362))
([63dd495](63dd495))


### Bug Fixes

* Fix a race condition when handling multiple flag updates.
([#365](#365))
([8d46bbd](8d46bbd))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@lexmarin
Copy link

lexmarin commented Oct 1, 2025

Thanks for fixing this! 🙇 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants