Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RG-2293 Get rid of side effects in setState updater function of Select #7574

Merged

Conversation

vkrol
Copy link
Contributor

@vkrol vkrol commented Jul 25, 2024

The setState updater function should be pure:

  1. https://react.dev/reference/react/useState#setstate-caveats:~:text=In Strict Mode%2C React will call your updater function twice
  2. https://react.dev/reference/react/useState#my-initializer-or-updater-function-runs-twice

In Strict Mode it is called twice in the development mode.

Side effects:

  1. this.props.onSelect && this.props.onSelect(selected, event);
  2. this.props.onDeselect && this.props.onDeselect(selected);
  3. (this.props.onChange as (selected: SelectItem<T>[], event?: Event) => void)(

@vkrol vkrol requested review from andrey-skl and Hypnosphi July 25, 2024 19:24
@vkrol vkrol changed the title RG-2293 Get rid of side effects in setState updater function of Selec… RG-2293 Get rid of side effects in setState updater function of Select Jul 25, 2024
@andrey-skl andrey-skl merged commit ce0e56c into master Jul 26, 2024
4 checks passed
@andrey-skl andrey-skl deleted the RG-2293-get-rid-of-side-effects-in-select-set-state branch July 26, 2024 08:32
vkrol added a commit that referenced this pull request Jul 26, 2024
andrey-skl added a commit that referenced this pull request Aug 21, 2024
* RG-2293 Get rid of side effects in setState updater function of Select component (#7574)

* 6.0.50

* RG-2462 switch sidebar and main background in dark theme (#7565)

(cherry picked from commit 647dd76)

* 6.0.51

* Support passing theme down via React Context (#7592)

* 6.0.52

* RG-2420 chore: undeprecate "Badge" in 6.x version

* Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]

* 6.0.53

* JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554 (#7637)

* RG-2473 don't unmount react root because it can be reused later (#7656)

minor: log auth error

* Revert "RG-2420 chore: undeprecate "Badge" in 6.x version"

This reverts commit 580369f.

---------

Co-authored-by: Veniamin Krol <[email protected]>
Co-authored-by: JetBrains Ring UI Automation <[email protected]>
andrey-skl added a commit that referenced this pull request Sep 4, 2024
* RG-2293 Get rid of side effects in setState updater function of Select component (#7574)

* 6.0.50

* RG-2462 switch sidebar and main background in dark theme (#7565)

(cherry picked from commit 647dd76)

* 6.0.51

* Support passing theme down via React Context (#7592)

* 6.0.52

* RG-2420 chore: undeprecate "Badge" in 6.x version

* Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]

* 6.0.53

* JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554 (#7637)

* RG-2473 don't unmount react root because it can be reused later (#7656)

minor: log auth error

* 6.0.54

* Revert "JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554"

This reverts commit 9192646.

* 6.0.55

* Put page reload in timeout for USER_CHANGED event to let all other events to be called. JT-83975 related

* 6.0.56

* Chore: add example with dialog with close button inside

* Revert "RG-2420 chore: undeprecate "Badge" in 6.x version"

This reverts commit 580369f.

---------

Co-authored-by: Veniamin Krol <[email protected]>
Co-authored-by: JetBrains Ring UI Automation <[email protected]>
andrey-skl added a commit that referenced this pull request Oct 21, 2024
* RG-2293 Get rid of side effects in setState updater function of Select component (#7574)

* 6.0.50

* RG-2462 switch sidebar and main background in dark theme (#7565)

(cherry picked from commit 647dd76)

* 6.0.51

* Support passing theme down via React Context (#7592)

* 6.0.52

* RG-2420 chore: undeprecate "Badge" in 6.x version

* Chore: export GLOBAL_DARK_CLASS_NAME constant [publish]

* 6.0.53

* JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554 (#7637)

* RG-2473 don't unmount react root because it can be reused later (#7656)

minor: log auth error

* 6.0.54

* Revert "JT-83359 Enable back controlling shortcuts by having '.ring-js-shortcuts' on parent, removed in 473d554"

This reverts commit 9192646.

* 6.0.55

* Put page reload in timeout for USER_CHANGED event to let all other events to be called. JT-83975 related

* 6.0.56

* Chore: add example with dialog with close button inside

* RG-2227 Clicking on a select label reopens the dropdown

(cherry picked from commit a685a07)

* chore: Prevent dialog scroll (#7710)

* chore: Prevent dialog scroll

* chore: preventBodyScroll should not be passed as a part of restProps

* 6.0.57

* Add attributes prop to DatePicker button (#7727)

Co-authored-by: Mikhail Cherviakov <[email protected]>

* 6.0.58

* [publish] fix breadcrumbs work with React.Fragment containers as a transparent containers

reactjs/rfcs#61

* 6.0.59

* Revert "[publish] fix breadcrumbs work with React.Fragment containers as a transparent containers"

This reverts commit 704bb21.

* 6.0.60

* Fix Table colspan calculation when columns is passed as function

* 6.0.61

* Get rid of unused Table maxColSpan prop

* RG-2490 support moving cursor from anchor to tooltip (#7754)

* RG-2490 support moving cursor from anchor to tooltip

* RG-2490 use React for "mouseout" event

* 6.0.62

* Check className in QueryAssist shouldComponentUpdate

* 6.0.63

---------

Co-authored-by: Veniamin Krol <[email protected]>
Co-authored-by: JetBrains Ring UI Automation <[email protected]>
Co-authored-by: Filipp Riabchun <[email protected]>
Co-authored-by: Alexander Burkov <[email protected]>
Co-authored-by: Mihail Ch. <[email protected]>
Co-authored-by: Mikhail Cherviakov <[email protected]>
Co-authored-by: maksim.erekhinskii <[email protected]>
Co-authored-by: Veniamin Krol <[email protected]>
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.

3 participants