Skip to content

Commit

Permalink
[change] Add className prop deprecation warning
Browse files Browse the repository at this point in the history
View and Text will not support the 'className' prop in a future release.

Fix #1146
  • Loading branch information
necolas committed Mar 12, 2019
1 parent 3308955 commit d50f630
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/react-native-web/src/exports/Text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { bool } from 'prop-types';
import { Component } from 'react';
import createElement from '../createElement';
import css from '../StyleSheet/css';
import warning from 'fbjs/lib/warning';
import StyleSheet from '../StyleSheet';
import TextPropTypes from './TextPropTypes';

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

const { isInAParentText } = this.context;

if (process.env.NODE_ENV !== 'production') {
warning(this.props.className == null, 'Using the "className" prop on <Text> is deprecated.');
}

if (onPress) {
otherProps.accessible = true;
otherProps.onClick = this._createPressHandler(onPress);
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-web/src/exports/View/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import createElement from '../createElement';
import css from '../StyleSheet/css';
import filterSupportedProps from './filterSupportedProps';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import StyleSheet from '../StyleSheet';
import ViewPropTypes, { type ViewProps } from './ViewPropTypes';
import React, { Component } from 'react';
Expand Down Expand Up @@ -42,6 +43,8 @@ class View extends Component<ViewProps> {
const supportedProps = filterSupportedProps(this.props);

if (process.env.NODE_ENV !== 'production') {
warning(this.props.className == null, 'Using the "className" prop on <View> is deprecated.');

React.Children.toArray(this.props.children).forEach(item => {
invariant(
typeof item !== 'string',
Expand Down

0 comments on commit d50f630

Please sign in to comment.