Skip to content

Commit

Permalink
chore: use ModernAutoControlled component (#3967)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Jun 24, 2020
1 parent ad47a6b commit 4c0ecc7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/addons/Pagination/Pagination.js
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'

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

this.trySetState({ activePage: nextActivePage })
this.setState({ activePage: nextActivePage })
_.invoke(this.props, 'onPageChange', e, { ...this.props, activePage: nextActivePage })
}

Expand Down
6 changes: 3 additions & 3 deletions src/addons/Portal/Portal.js
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types'
import React, { cloneElement, createRef, Fragment } from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
customPropTypes,
doesNodeContainClick,
makeDebugger,
Expand Down Expand Up @@ -285,7 +285,7 @@ class Portal extends Component {
const { onOpen } = this.props
if (onOpen) onOpen(e, this.props)

this.trySetState({ open: true })
this.setState({ open: true })
}

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

this.trySetState({ open: false })
this.setState({ open: false })
}

closeWithTimeout = (e, delay) => {
Expand Down
4 changes: 2 additions & 2 deletions src/collections/Menu/Menu.js
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
childrenUtils,
customPropTypes,
createShorthandFactory,
Expand Down Expand Up @@ -117,7 +117,7 @@ class Menu extends Component {
onClick: (e, itemProps) => {
const { index } = itemProps

this.trySetState({ activeIndex: index })
this.setState({ activeIndex: index })

_.invoke(predefinedProps, 'onClick', e, itemProps)
_.invoke(this.props, 'onItemClick', e, itemProps)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Accordion/AccordionAccordion.js
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
childrenUtils,
createShorthandFactory,
customPropTypes,
Expand Down Expand Up @@ -110,7 +110,7 @@ export default class AccordionAccordion extends Component {
handleTitleClick = (e, titleProps) => {
const { index } = titleProps

this.trySetState({ activeIndex: this.computeNewIndex(index) })
this.setState({ activeIndex: this.computeNewIndex(index) })
_.invoke(this.props, 'onTitleClick', e, titleProps)
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/Checkbox/Checkbox.js
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
import React, { createRef } from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
createHTMLLabel,
customPropTypes,
getElementType,
Expand Down Expand Up @@ -195,7 +195,7 @@ export default class Checkbox extends Component {
checked: !checked,
indeterminate: false,
})
this.trySetState({ checked: !checked, indeterminate: false })
this.setState({ checked: !checked, indeterminate: false })
}

handleMouseDown = (e) => {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Embed/Embed.js
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
childrenUtils,
createHTMLIframe,
customPropTypes,
Expand Down Expand Up @@ -130,7 +130,7 @@ export default class Embed extends Component {
const { active } = this.state

if (onClick) onClick(e, { ...this.props, active: true })
if (!active) this.trySetState({ active: true })
if (!active) this.setState({ active: true })
}

render() {
Expand Down
8 changes: 4 additions & 4 deletions src/modules/Modal/Modal.js
Expand Up @@ -6,7 +6,7 @@ import React, { createRef, Fragment, isValidElement } from 'react'
import shallowEqual from 'shallowequal'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
childrenUtils,
customPropTypes,
doesNodeContainClick,
Expand Down Expand Up @@ -179,7 +179,7 @@ class Modal extends Component {
debug('close()')

_.invoke(this.props, 'onClose', e, this.props)
this.trySetState({ open: false })
this.setState({ open: false })
}

handleDocumentMouseDown = (e) => {
Expand All @@ -200,7 +200,7 @@ class Modal extends Component {
return

_.invoke(this.props, 'onClose', e, this.props)
this.trySetState({ open: false })
this.setState({ open: false })
}

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

_.invoke(this.props, 'onOpen', e, this.props)
this.trySetState({ open: true })
this.setState({ open: true })
}

handlePortalMount = (e) => {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Rating/Rating.js
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
getElementType,
getUnhandledProps,
SUI,
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class Rating extends Component {
}

// set rating
this.trySetState({ rating: newRating, isSelecting: false })
this.setState({ rating: newRating, isSelecting: false })
if (onRate) onRate(e, { ...this.props, rating: newRating })
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/Tab/Tab.js
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'

import {
AutoControlledComponent as Component,
ModernAutoControlledComponent as Component,
customPropTypes,
getElementType,
getUnhandledProps,
Expand Down Expand Up @@ -84,7 +84,7 @@ class Tab extends Component {

handleItemClick = (e, { index }) => {
_.invoke(this.props, 'onTabChange', e, { ...this.props, activeIndex: index })
this.trySetState({ activeIndex: index })
this.setState({ activeIndex: index })
}

renderItems() {
Expand Down

0 comments on commit 4c0ecc7

Please sign in to comment.