Skip to content

Commit 4c0ecc7

Browse files
authored
chore: use ModernAutoControlled component (#3967)
1 parent ad47a6b commit 4c0ecc7

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

src/addons/Pagination/Pagination.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33
import React from 'react'
44

55
import {
6-
AutoControlledComponent as Component,
6+
ModernAutoControlledComponent as Component,
77
createPaginationItems,
88
customPropTypes,
99
getUnhandledProps,
@@ -98,7 +98,7 @@ export default class Pagination extends Component {
9898
// Heads up! We need the cast to the "number" type there, as `activePage` can be a string
9999
if (+prevActivePage === +nextActivePage) return
100100

101-
this.trySetState({ activePage: nextActivePage })
101+
this.setState({ activePage: nextActivePage })
102102
_.invoke(this.props, 'onPageChange', e, { ...this.props, activePage: nextActivePage })
103103
}
104104

src/addons/Portal/Portal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types'
66
import React, { cloneElement, createRef, Fragment } from 'react'
77

88
import {
9-
AutoControlledComponent as Component,
9+
ModernAutoControlledComponent as Component,
1010
customPropTypes,
1111
doesNodeContainClick,
1212
makeDebugger,
@@ -285,7 +285,7 @@ class Portal extends Component {
285285
const { onOpen } = this.props
286286
if (onOpen) onOpen(e, this.props)
287287

288-
this.trySetState({ open: true })
288+
this.setState({ open: true })
289289
}
290290

291291
openWithTimeout = (e, delay) => {
@@ -303,7 +303,7 @@ class Portal extends Component {
303303
const { onClose } = this.props
304304
if (onClose) onClose(e, this.props)
305305

306-
this.trySetState({ open: false })
306+
this.setState({ open: false })
307307
}
308308

309309
closeWithTimeout = (e, delay) => {

src/collections/Menu/Menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
44
import React from 'react'
55

66
import {
7-
AutoControlledComponent as Component,
7+
ModernAutoControlledComponent as Component,
88
childrenUtils,
99
customPropTypes,
1010
createShorthandFactory,
@@ -117,7 +117,7 @@ class Menu extends Component {
117117
onClick: (e, itemProps) => {
118118
const { index } = itemProps
119119

120-
this.trySetState({ activeIndex: index })
120+
this.setState({ activeIndex: index })
121121

122122
_.invoke(predefinedProps, 'onClick', e, itemProps)
123123
_.invoke(this.props, 'onItemClick', e, itemProps)

src/modules/Accordion/AccordionAccordion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
44
import React from 'react'
55

66
import {
7-
AutoControlledComponent as Component,
7+
ModernAutoControlledComponent as Component,
88
childrenUtils,
99
createShorthandFactory,
1010
customPropTypes,
@@ -110,7 +110,7 @@ export default class AccordionAccordion extends Component {
110110
handleTitleClick = (e, titleProps) => {
111111
const { index } = titleProps
112112

113-
this.trySetState({ activeIndex: this.computeNewIndex(index) })
113+
this.setState({ activeIndex: this.computeNewIndex(index) })
114114
_.invoke(this.props, 'onTitleClick', e, titleProps)
115115
}
116116

src/modules/Checkbox/Checkbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
55
import React, { createRef } from 'react'
66

77
import {
8-
AutoControlledComponent as Component,
8+
ModernAutoControlledComponent as Component,
99
createHTMLLabel,
1010
customPropTypes,
1111
getElementType,
@@ -195,7 +195,7 @@ export default class Checkbox extends Component {
195195
checked: !checked,
196196
indeterminate: false,
197197
})
198-
this.trySetState({ checked: !checked, indeterminate: false })
198+
this.setState({ checked: !checked, indeterminate: false })
199199
}
200200

201201
handleMouseDown = (e) => {

src/modules/Embed/Embed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33
import React from 'react'
44

55
import {
6-
AutoControlledComponent as Component,
6+
ModernAutoControlledComponent as Component,
77
childrenUtils,
88
createHTMLIframe,
99
customPropTypes,
@@ -130,7 +130,7 @@ export default class Embed extends Component {
130130
const { active } = this.state
131131

132132
if (onClick) onClick(e, { ...this.props, active: true })
133-
if (!active) this.trySetState({ active: true })
133+
if (!active) this.setState({ active: true })
134134
}
135135

136136
render() {

src/modules/Modal/Modal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React, { createRef, Fragment, isValidElement } from 'react'
66
import shallowEqual from 'shallowequal'
77

88
import {
9-
AutoControlledComponent as Component,
9+
ModernAutoControlledComponent as Component,
1010
childrenUtils,
1111
customPropTypes,
1212
doesNodeContainClick,
@@ -179,7 +179,7 @@ class Modal extends Component {
179179
debug('close()')
180180

181181
_.invoke(this.props, 'onClose', e, this.props)
182-
this.trySetState({ open: false })
182+
this.setState({ open: false })
183183
}
184184

185185
handleDocumentMouseDown = (e) => {
@@ -200,7 +200,7 @@ class Modal extends Component {
200200
return
201201

202202
_.invoke(this.props, 'onClose', e, this.props)
203-
this.trySetState({ open: false })
203+
this.setState({ open: false })
204204
}
205205

206206
handleIconOverrides = (predefinedProps) => ({
@@ -214,7 +214,7 @@ class Modal extends Component {
214214
debug('open()')
215215

216216
_.invoke(this.props, 'onOpen', e, this.props)
217-
this.trySetState({ open: true })
217+
this.setState({ open: true })
218218
}
219219

220220
handlePortalMount = (e) => {

src/modules/Rating/Rating.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
44
import React from 'react'
55

66
import {
7-
AutoControlledComponent as Component,
7+
ModernAutoControlledComponent as Component,
88
getElementType,
99
getUnhandledProps,
1010
SUI,
@@ -82,7 +82,7 @@ export default class Rating extends Component {
8282
}
8383

8484
// set rating
85-
this.trySetState({ rating: newRating, isSelecting: false })
85+
this.setState({ rating: newRating, isSelecting: false })
8686
if (onRate) onRate(e, { ...this.props, rating: newRating })
8787
}
8888

src/modules/Tab/Tab.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33
import React from 'react'
44

55
import {
6-
AutoControlledComponent as Component,
6+
ModernAutoControlledComponent as Component,
77
customPropTypes,
88
getElementType,
99
getUnhandledProps,
@@ -84,7 +84,7 @@ class Tab extends Component {
8484

8585
handleItemClick = (e, { index }) => {
8686
_.invoke(this.props, 'onTabChange', e, { ...this.props, activeIndex: index })
87-
this.trySetState({ activeIndex: index })
87+
this.setState({ activeIndex: index })
8888
}
8989

9090
renderItems() {

0 commit comments

Comments
 (0)