Skip to content

Commit d50f630

Browse files
committed
[change] Add className prop deprecation warning
View and Text will not support the 'className' prop in a future release. Fix #1146
1 parent 3308955 commit d50f630

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/react-native-web/src/exports/Text/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { bool } from 'prop-types';
1414
import { Component } from 'react';
1515
import createElement from '../createElement';
1616
import css from '../StyleSheet/css';
17+
import warning from 'fbjs/lib/warning';
1718
import StyleSheet from '../StyleSheet';
1819
import TextPropTypes from './TextPropTypes';
1920

@@ -60,6 +61,10 @@ class Text extends Component<*> {
6061

6162
const { isInAParentText } = this.context;
6263

64+
if (process.env.NODE_ENV !== 'production') {
65+
warning(this.props.className == null, 'Using the "className" prop on <Text> is deprecated.');
66+
}
67+
6368
if (onPress) {
6469
otherProps.accessible = true;
6570
otherProps.onClick = this._createPressHandler(onPress);

packages/react-native-web/src/exports/View/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import createElement from '../createElement';
1313
import css from '../StyleSheet/css';
1414
import filterSupportedProps from './filterSupportedProps';
1515
import invariant from 'fbjs/lib/invariant';
16+
import warning from 'fbjs/lib/warning';
1617
import StyleSheet from '../StyleSheet';
1718
import ViewPropTypes, { type ViewProps } from './ViewPropTypes';
1819
import React, { Component } from 'react';
@@ -42,6 +43,8 @@ class View extends Component<ViewProps> {
4243
const supportedProps = filterSupportedProps(this.props);
4344

4445
if (process.env.NODE_ENV !== 'production') {
46+
warning(this.props.className == null, 'Using the "className" prop on <View> is deprecated.');
47+
4548
React.Children.toArray(this.props.children).forEach(item => {
4649
invariant(
4750
typeof item !== 'string',

0 commit comments

Comments
 (0)