Skip to content

Commit

Permalink
add a warning for render
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Jul 30, 2020
1 parent 10c10db commit b1b675a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/addons/Responsive/Responsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ export default class Responsive extends Component {
componentDidMount() {
const { fireOnMount } = this.props

if (process.env.NODE_ENV !== 'production') {
if (!Responsive.__deprecationWarningWasRaised) {
Responsive.__deprecationWarningWasRaised = true

// eslint-disable-next-line no-console
console.warn(
'Warning: "Responsive" component from Semantic UI React is deprecated and will be removed in the next major release. Please follow our upgrade guide: https://github.com/Semantic-Org/Semantic-UI-React/pull/4008',
)
}
}

eventStack.sub('resize', this.handleResize, { target: 'window' })
if (fireOnMount) this.handleUpdate()
}
Expand Down Expand Up @@ -112,3 +123,7 @@ Responsive.onlyTablet = { minWidth: 768, maxWidth: 991 }
Responsive.onlyComputer = { minWidth: 992 }
Responsive.onlyLargeScreen = { minWidth: 1200, maxWidth: 1919 }
Responsive.onlyWidescreen = { minWidth: 1920 }

if (process.env.NODE_ENV !== 'production') {
Responsive.__deprecationWarningWasRaised = false
}
7 changes: 6 additions & 1 deletion test/specs/addons/Responsive/Responsive-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import React from 'react'
import Responsive from 'src/addons/Responsive/Responsive'
import { isBrowser } from 'src/lib'
import * as common from 'test/specs/commonTests'
import { domEvent, sandbox } from 'test/utils'
import { consoleUtil, domEvent, sandbox } from 'test/utils'

describe('Responsive', () => {
it('a render to strip deprecation warning', () => {
consoleUtil.disableOnce()
mount(<Responsive />)
})

common.isConformant(Responsive)
common.rendersChildren(Responsive, {
rendersContent: false,
Expand Down

0 comments on commit b1b675a

Please sign in to comment.