From b1b675ae2e0f1c63f97b22815bb9abfe3373223f Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 30 Jul 2020 10:34:58 +0200 Subject: [PATCH] add a warning for render --- src/addons/Responsive/Responsive.js | 15 +++++++++++++++ test/specs/addons/Responsive/Responsive-test.js | 7 ++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/addons/Responsive/Responsive.js b/src/addons/Responsive/Responsive.js index e77b97d6ab..92e06760a3 100644 --- a/src/addons/Responsive/Responsive.js +++ b/src/addons/Responsive/Responsive.js @@ -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() } @@ -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 +} diff --git a/test/specs/addons/Responsive/Responsive-test.js b/test/specs/addons/Responsive/Responsive-test.js index 28b1ef90ae..8a92dfba42 100644 --- a/test/specs/addons/Responsive/Responsive-test.js +++ b/test/specs/addons/Responsive/Responsive-test.js @@ -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() + }) + common.isConformant(Responsive) common.rendersChildren(Responsive, { rendersContent: false,