Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade React Native to 0.74.0 with minimal dependency changes #3514

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions demo/src/screens/DemoScreen.js → demo/src/screens/DemoScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import {ScrollView, Switch} from 'react-native';
import {View, TextField, Text, Badge, Colors} from 'react-native-ui-lib';//eslint-disable-line
import {View, TextField, Text, Colors} from 'react-native-ui-lib';//eslint-disable-line

export default class DemoScreen extends Component {
interface Props {
getComponent: () => any; // TODO: Add proper type for the component
}

interface State {
backgroundColor: string;
label: string;
[key: string]: any; // For dynamic props
}

constructor(props) {
type PropType = 'string' | 'number' | 'boolean';

export default class DemoScreen extends Component<Props, State> {
private propsToRender?: string[];

constructor(props: Props) {
super(props);

this.state = {
backgroundColor: Colors.red50,
label: '12',
label: '12'
};

this.updatePropValue = this.updatePropValue.bind(this);
Expand All @@ -22,11 +34,12 @@ export default class DemoScreen extends Component {
}

getComponentProps() {
const DemoComponent = this.getComponent();
return DemoComponent.propTypes;
this.props.getComponent();
// Note: Component props should be accessed via type system instead of runtime
return {};
}

shouldRenderProp(propId) {
shouldRenderProp(propId: string) {
let shouldRender = true;
shouldRender = shouldRender && propId !== 'testID';
if (this.propsToRender) {
Expand All @@ -35,59 +48,56 @@ export default class DemoScreen extends Component {
return shouldRender;
}

updatePropValue(value, propId, prop) {
updatePropValue(value: any, propId: string, propType: PropType) {
let validValue = value;

if (prop === PropTypes.number) {
if (propType === 'number') {
validValue = isNaN(value) ? undefined : Number(value);
}

this.setState({
[propId]: validValue,
[propId]: validValue
});
}

renderProp(propType: PropType, propId: string) {
if (!this.shouldRenderProp(propId)) return null;

renderProp(prop, propId) {
if (!this.shouldRenderProp(propId)) return;

if (PropTypes.bool === prop) {
if (propType === 'boolean') {
return (
<View row spread key={propId} paddingV-10>
<Text test70 grey60>
{propId}
</Text>
<Switch
value={this.state[propId]}
onValueChange={value => this.updatePropValue(value, propId, prop)}
onValueChange={(value: boolean) => this.updatePropValue(value, propId, propType)}
/>
</View>
);
}

// if (_.includes([PropTypes.string, PropTypes.number], prop)) {
return (
<View key={propId}>
<TextField
placeholder={propId}
floatingPlaceholder
enableError={false}
value={this.state[propId]}
onChangeText={text => this.updatePropValue(text, propId, prop)}
onChangeText={(text: string) => this.updatePropValue(text, propId, propType)}
autoCapitalize='none'
/>
</View>
);
// }
}

renderComponentSettings() {
const props = this.getComponentProps();
return (
<ScrollView keyboardShouldPersistTaps>
<View padding-15>
{_.map(props, (prop, propId) => {
return this.renderProp(prop, propId);
{_.map(props, (propType, propId) => {
return this.renderProp(propType as PropType, propId);
})}
</View>
</ScrollView>
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@babel/cli": "^7.16.8",
"@babel/core": "^7.24.4",
"@babel/plugin-transform-modules-commonjs": "^7.17.9",
"@babel/preset-env": "^7.20.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.10.1",
"@babel/runtime": "^7.20.0",
"@formatjs/intl-datetimeformat": "^6.0.3",
Expand All @@ -73,10 +73,11 @@
"@react-native-community/blur": "4.4.1",
"@react-native-community/datetimepicker": "^3.4.6",
"@react-native-community/netinfo": "^5.6.2",
"@react-native/babel-preset": "0.73.21",
"@react-native/eslint-config": "0.73.2",
"@react-native/metro-config": "0.73.5",
"@react-native/typescript-config": "0.73.1",
"@react-native/babel-preset": "0.74.0",
"@react-native/eslint-config": "0.74.0",
"@react-native/metro-config": "0.74.0",
"@react-native/typescript-config": "0.74.0",
"@babel/core": "^7.24.0",
"@shopify/flash-list": "^1.2.1",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react-native": "^11.5.1",
Expand All @@ -102,7 +103,7 @@
"eslint-plugin-react-native": "^4.0.0",
"jest": "^29.6.3",
"light-date": "^1.2.0",
"metro-react-native-babel-preset": "0.73.10",
"metro-react-native-babel-preset": "0.74.0",
"moment": "^2.24.0",
"object-hash": "^3.0.0",
"postcss": "^8.4.21",
Expand All @@ -111,8 +112,8 @@
"prettier-eslint": "16.3.0",
"react": "18.2.0",
"react-autobind": "^1.0.6",
"react-dom": "^18.2.0",
"react-native": "0.73.9",
"react-dom": "^18.3.1",
"react-native": "0.74.0",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "2.14.1",
"react-native-haptic-feedback": "^1.11.0",
Expand All @@ -123,7 +124,7 @@
"react-native-shimmer-placeholder": "^2.0.6",
"react-native-svg": "15.2.0",
"react-native-svg-transformer": "1.5.0",
"react-test-renderer": "18.2.0",
"react-test-renderer": "18.3.1",
"reassure": "^0.4.1",
"shell-utils": "^1.0.10",
"typescript": "5.0.4"
Expand Down
Loading