Skip to content

Commit

Permalink
Remove API deprecation warnings
Browse files Browse the repository at this point in the history
Removes warnings for non-standard APIs in React Native, given there has
been no upstream interest in deprecating them. And the standards-based
approach to cross-platform React is instead being built into React
Strict DOM.
  • Loading branch information
necolas committed Oct 17, 2024
1 parent abc4abb commit fc423ba
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Accessibility in {{ site.name }} combines several separate web APIs into a cohes

## Accessibility Props API

{{ site.name }} includes APIs for making accessible apps. (Note that the React Native-specific `accessibility*` props are deprecated in favor of `aria-*` props).
{{ site.name }} includes APIs for making accessible apps. (Note that for compatibility with existing React Native code, the React Native-specific `accessibility*` props are also supported.)

{% call macro.prop('aria-activedescendant', '?string') %}
Equivalent to [aria-activedescendant](https://www.w3.org/TR/wai-aria-1.2/#aria-activedescendant).
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-web/src/exports/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as React from 'react';
import StyleSheet from '../StyleSheet';
import TouchableOpacity from '../TouchableOpacity';
import Text from '../Text';
import { warnOnce } from '../../modules/warnOnce';
//import { warnOnce } from '../../modules/warnOnce';

type ButtonProps = {|
accessibilityLabel?: ?string,
Expand All @@ -27,7 +27,7 @@ const Button: React.AbstractComponent<
ButtonProps,
React.ElementRef<typeof TouchableOpacity>
> = React.forwardRef((props, forwardedRef) => {
warnOnce('Button', 'Button is deprecated. Please use Pressable.');
// warnOnce('Button', 'Button is deprecated. Please use Pressable.');

const { accessibilityLabel, color, disabled, onPress, testID, title } = props;

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/StyleSheet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ function compose(style1: any, style2: any): any {
);
}
/* eslint-enable prefer-rest-params */
/*
console.warn(
'StyleSheet.compose(a, b) is deprecated; use array syntax, i.e., [a,b].'
);
*/
}
return [style1, style2];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,22 @@ export const preprocess = <T: {| [key: string]: any |}>(
nextStyle[prop] = value.toString();
} else if (prop === 'fontVariant') {
if (Array.isArray(value) && value.length > 0) {
/*
warnOnce(
'fontVariant',
'"fontVariant" style array value is deprecated. Use space-separated values.'
);
*/
value = value.join(' ');
}
nextStyle[prop] = value;
} else if (prop === 'textAlignVertical') {
/*
warnOnce(
'textAlignVertical',
'"textAlignVertical" style is deprecated. Use "verticalAlign".'
);
*/
if (style.verticalAlign == null) {
nextStyle.verticalAlign = value === 'center' ? 'middle' : value;
}
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native-web/src/exports/Text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import useResponderEvents from '../../modules/useResponderEvents';
import StyleSheet from '../StyleSheet';
import TextAncestorContext from './TextAncestorContext';
import { useLocaleContext, getLocaleDirection } from '../../modules/useLocale';
import { warnOnce } from '../../modules/warnOnce';
//import { warnOnce } from '../../modules/warnOnce';

const forwardPropsList = Object.assign(
{},
Expand Down Expand Up @@ -73,12 +73,14 @@ const Text: React.AbstractComponent<TextProps, HTMLElement & PlatformMethods> =
...rest
} = props;

/*
if (selectable != null) {
warnOnce(
'selectable',
'selectable prop is deprecated. Use styles.userSelect.'
);
}
*/

const hasTextAncestor = React.useContext(TextAncestorContext);
const hostRef = React.useRef(null);
Expand Down
10 changes: 8 additions & 2 deletions packages/react-native-web/src/exports/TextInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import useResponderEvents from '../../modules/useResponderEvents';
import { getLocaleDirection, useLocaleContext } from '../../modules/useLocale';
import StyleSheet from '../StyleSheet';
import TextInputState from '../../modules/TextInputState';
import { warnOnce } from '../../modules/warnOnce';
//import { warnOnce } from '../../modules/warnOnce';

/**
* Determines whether a 'selection' prop differs from a node's existing
Expand Down Expand Up @@ -163,7 +163,7 @@ const TextInput: React.AbstractComponent<
type = 'text';
}
} else if (keyboardType != null) {
warnOnce('keyboardType', 'keyboardType is deprecated. Use inputMode.');
// warnOnce('keyboardType', 'keyboardType is deprecated. Use inputMode.');
switch (keyboardType) {
case 'email-address':
type = 'email';
Expand Down Expand Up @@ -394,26 +394,32 @@ const TextInput: React.AbstractComponent<
supportedProps.autoCorrect = autoCorrect ? 'on' : 'off';
// 'auto' by default allows browsers to infer writing direction
supportedProps.dir = dir !== undefined ? dir : 'auto';
/*
if (returnKeyType != null) {
warnOnce('returnKeyType', 'returnKeyType is deprecated. Use enterKeyHint.');
}
*/
supportedProps.enterKeyHint = enterKeyHint || returnKeyType;
supportedProps.inputMode = _inputMode;
supportedProps.onBlur = handleBlur;
supportedProps.onChange = handleChange;
supportedProps.onFocus = handleFocus;
supportedProps.onKeyDown = handleKeyDown;
supportedProps.onSelect = handleSelectionChange;
/*
if (editable != null) {
warnOnce('editable', 'editable is deprecated. Use readOnly.');
}
*/
supportedProps.readOnly = readOnly === true || editable === false;
/*
if (numberOfLines != null) {
warnOnce(
'numberOfLines',
'TextInput numberOfLines is deprecated. Use rows.'
);
}
*/
supportedProps.rows = multiline ? (rows != null ? rows : numberOfLines) : 1;
supportedProps.spellCheck = spellCheck != null ? spellCheck : autoCorrect;
supportedProps.style = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import useMergeRefs from '../../modules/useMergeRefs';
import usePressEvents from '../../modules/usePressEvents';
import StyleSheet from '../StyleSheet';
import View from '../View';
import { warnOnce } from '../../modules/warnOnce';
//import { warnOnce } from '../../modules/warnOnce';

type ViewStyle = $PropertyType<ViewProps, 'style'>;

Expand Down Expand Up @@ -71,10 +71,12 @@ function hasPressHandler(props): boolean {
* If you wish to have several child components, wrap them in a View.
*/
function TouchableHighlight(props: Props, forwardedRef): React.Node {
/*
warnOnce(
'TouchableHighlight',
'TouchableHighlight is deprecated. Please use Pressable.'
);
*/

const {
activeOpacity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import useMergeRefs from '../../modules/useMergeRefs';
import usePressEvents from '../../modules/usePressEvents';
import StyleSheet from '../StyleSheet';
import View from '../View';
import { warnOnce } from '../../modules/warnOnce';
//import { warnOnce } from '../../modules/warnOnce';

type ViewStyle = $PropertyType<ViewProps, 'style'>;

Expand All @@ -34,10 +34,12 @@ type Props = $ReadOnly<{|
* On press down, the opacity of the wrapped view is decreased, dimming it.
*/
function TouchableOpacity(props: Props, forwardedRef): React.Node {
/*
warnOnce(
'TouchableOpacity',
'TouchableOpacity is deprecated. Please use Pressable.'
);
*/

const {
activeOpacity,
Expand Down
Loading

0 comments on commit fc423ba

Please sign in to comment.