Skip to content
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
4 changes: 2 additions & 2 deletions packages/debugger-frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @noformat
* @format
*/

const path = require('path');
Expand Down Expand Up @@ -33,4 +33,4 @@ if (process.env.REACT_NATIVE_DEBUGGER_FRONTEND_PATH != null) {
);
}

module.exports = (frontEndPath /*: string */);
module.exports = frontEndPath /*:: as string */;
2 changes: 2 additions & 0 deletions packages/helloworld/.prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

'use strict';
Expand Down
64 changes: 48 additions & 16 deletions packages/react-native-codegen-typescript-test/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,45 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @lint-ignore-every LICENSELINT
*/

const fs = require('fs');
const path = require('path');

const tsComponentFixturePath = path.join(__dirname, '../../react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js');
const tsComponentSnapshotPath = path.join(__dirname, '../../react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap');
const tsModuleFixturePath = path.join(__dirname, '../../react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js');
const tsModuleSnapshotPath = path.join(__dirname, '../../react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap');
const tsComponentFixturePath = path.join(
__dirname,
'../../react-native-codegen/src/parsers/typescript/components/__test_fixtures__/fixtures.js',
);
const tsComponentSnapshotPath = path.join(
__dirname,
'../../react-native-codegen/src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap',
);
const tsModuleFixturePath = path.join(
__dirname,
'../../react-native-codegen/src/parsers/typescript/modules/__test_fixtures__/fixtures.js',
);
const tsModuleSnapshotPath = path.join(
__dirname,
'../../react-native-codegen/src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap',
);
const snapshotOutputPath = path.join(__dirname, '../__generated__');

function genereateSnapshotTestCases(name, fixturePath, snapshotPath, outputPath) {
const fixtures = require(fixturePath);
const snapshots = require(snapshotPath);
for (const key of Object.keys(fixtures)) {
const snapshotName = `RN Codegen TypeScript Parser can generate fixture ${key} 1`;
const snapshotString = snapshots[snapshotName];
const snapshot = snapshotString.substring(2, snapshotString.length - 2);
const tsSourceCode = `
function genereateSnapshotTestCases(
name,
fixturePath,
snapshotPath,
outputPath,
) {
const fixtures = require(fixturePath);
const snapshots = require(snapshotPath);
for (const key of Object.keys(fixtures)) {
const snapshotName = `RN Codegen TypeScript Parser can generate fixture ${key} 1`;
const snapshotString = snapshots[snapshotName];
const snapshot = snapshotString.substring(2, snapshotString.length - 2);
const tsSourceCode = `
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
Expand All @@ -34,9 +54,21 @@ import type { SchemaType } from '@react-native/codegen/lib/CodegenSchema';
const snapshot : SchemaType = ${snapshot};
export default snapshot;
`;
fs.writeFileSync(path.join(outputPath, `${name}_${key}.ts`), tsSourceCode, { encoding: 'utf-8' });
}
fs.writeFileSync(path.join(outputPath, `${name}_${key}.ts`), tsSourceCode, {
encoding: 'utf-8',
});
}
}

genereateSnapshotTestCases('component', tsComponentFixturePath, tsComponentSnapshotPath, snapshotOutputPath);
genereateSnapshotTestCases('module', tsModuleFixturePath, tsModuleSnapshotPath, snapshotOutputPath);
genereateSnapshotTestCases(
'component',
tsComponentFixturePath,
tsComponentSnapshotPath,
snapshotOutputPath,
);
genereateSnapshotTestCases(
'module',
tsModuleFixturePath,
tsModuleSnapshotPath,
snapshotOutputPath,
);
27 changes: 14 additions & 13 deletions packages/react-native-fantom/src/__tests__/Fantom-itest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {HostInstance} from 'react-native';

import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {LogBox, Modal, ScrollView, Text, TextInput, View} from 'react-native';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import NativeFantom from 'react-native/src/private/testing/fantom/specs/NativeFantom';
Expand Down Expand Up @@ -552,7 +553,7 @@ describe('Fantom', () => {

let focusEvent = jest.fn();

const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(<TextInput onFocus={focusEvent} ref={ref} />);
Expand All @@ -576,7 +577,7 @@ describe('Fantom', () => {

it('sends event with payload', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();
const onChange = jest.fn();

Fantom.runTask(() => {
Expand Down Expand Up @@ -607,7 +608,7 @@ describe('Fantom', () => {

it('it batches events with isUnique option', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();
const onScroll = jest.fn();

Fantom.runTask(() => {
Expand Down Expand Up @@ -666,7 +667,7 @@ describe('Fantom', () => {
describe('dispatchNativeEvent', () => {
it('flushes the event and runs the work loop', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();

let focusEvent = jest.fn();

Expand All @@ -687,7 +688,7 @@ describe('Fantom', () => {
describe('enqueueScrollEvent', () => {
it('throws error if called on node that is not scroll view', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(<View ref={ref} />);
Expand All @@ -709,8 +710,8 @@ describe('Fantom', () => {

it('delivers onScroll event and affects position of elements on screen', () => {
const root = Fantom.createRoot();
const viewRef = React.createRef<HostInstance>();
const scrollViewRef = React.createRef<HostInstance>();
const viewRef = createRef<HostInstance>();
const scrollViewRef = createRef<HostInstance>();
const onScroll = jest.fn();

Fantom.runTask(() => {
Expand Down Expand Up @@ -778,7 +779,7 @@ describe('Fantom', () => {
describe('scrollTo', () => {
it('throws error if called on node that is not scroll view', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(<View ref={ref} />);
Expand All @@ -798,8 +799,8 @@ describe('Fantom', () => {

it('delivers onScroll event and affects position of elements on screen', () => {
const root = Fantom.createRoot();
const scrollViewRef = React.createRef<HostInstance>();
const viewRef = React.createRef<HostInstance>();
const scrollViewRef = createRef<HostInstance>();
const viewRef = createRef<HostInstance>();
const onScroll = jest.fn();

Fantom.runTask(() => {
Expand Down Expand Up @@ -890,7 +891,7 @@ describe('Fantom', () => {
describe('enqueueModalSizeUpdate', () => {
it('throws error if called on node that is not <Modal />', () => {
const root = Fantom.createRoot();
const ref = React.createRef<HostInstance>();
const ref = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(<View ref={ref} />);
Expand All @@ -912,8 +913,8 @@ describe('Fantom', () => {

it('change size of <Modal />', () => {
const root = Fantom.createRoot();
const modalNodeRef = React.createRef<HostInstance>();
const viewNodeRef = React.createRef<HostInstance>();
const modalNodeRef = createRef<HostInstance>();
const viewNodeRef = createRef<HostInstance>();

Fantom.runTask(() => {
root.render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

module.exports = {
dependency: {
platforms: {
android: {
'cmakeListsPath': '../android/src/main/jni/CMakeLists.txt',
cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

/*
Expand All @@ -26,7 +28,9 @@ const fs = require('fs');
const buildGradleKtsPath = 'android/build.gradle.kts';
const libsVersionsTomlPath = '../react-native/gradle/libs.versions.toml';

console.log(`Updating ${buildGradleKtsPath} with versions from ${libsVersionsTomlPath}...`);
console.log(
`Updating ${buildGradleKtsPath} with versions from ${libsVersionsTomlPath}...`,
);

let gradleContent = fs.readFileSync(buildGradleKtsPath, 'utf8');
const tomlContent = fs.readFileSync(libsVersionsTomlPath, 'utf8');
Expand All @@ -39,7 +43,10 @@ gradleContent = gradleContent
.replace('libs.versions.compileSdk.get().toInt()', compileSdk)
.replace('libs.versions.minSdk.get().toInt()', minSdk)
.replace('libs.versions.buildTools.get()', `"${buildTools}"`)
.replace('project(":packages:react-native:ReactAndroid")', '"com.facebook.react:react-android"');
.replace(
'project(":packages:react-native:ReactAndroid")',
'"com.facebook.react:react-android"',
);

fs.writeFileSync(buildGradleKtsPath, gradleContent);

Expand Down
9 changes: 8 additions & 1 deletion packages/react-native-test-library/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

module.exports = {
presets: [['module:@react-native/babel-preset', {disableStaticViewConfigsCodegen: false}]],
presets: [
[
'module:@react-native/babel-preset',
{disableStaticViewConfigsCodegen: false},
],
],
};
4 changes: 3 additions & 1 deletion packages/react-native-test-library/react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

module.exports = {
dependency: {
platforms: {
android: {
'cmakeListsPath': '../android/src/main/jni/CMakeLists.txt',
cmakeListsPath: '../android/src/main/jni/CMakeLists.txt',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import useMergeRefs from '../../Utilities/useMergeRefs';
import createAnimatedComponent from '../createAnimatedComponent';
import useAnimatedProps from '../useAnimatedProps';
import * as React from 'react';
import {useMemo} from 'react';
import {cloneElement, useMemo} from 'react';

type AnimatedScrollViewProps = React.ElementConfig<typeof ScrollView>;
type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
Expand Down Expand Up @@ -104,7 +104,7 @@ const AnimatedScrollViewWithInvertedRefreshControl =
// NOTE: Assumes that refreshControl.ref` and `refreshControl.style` can be
// safely clobbered.
const refreshControl: ExactReactElement_DEPRECATED<typeof RefreshControl> =
React.cloneElement(props.refreshControl, {
cloneElement(props.refreshControl, {
...refreshControlAnimatedProps,
ref: refreshControlRef,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {AnimatedNodeConfig} from './AnimatedNode';

import AnimatedNode from './AnimatedNode';
import AnimatedWithChildren from './AnimatedWithChildren';
import * as React from 'react';
import {isValidElement} from 'react';

const MAX_DEPTH = 5;

Expand All @@ -30,7 +30,7 @@ export function isPlainObject(
value !== null &&
typeof value === 'object' &&
Object.getPrototypeOf(value).isPrototypeOf(Object) &&
!React.isValidElement(value)
!isValidElement(value)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import AndroidDrawerLayoutNativeComponent, {
} from './AndroidDrawerLayoutNativeComponent';
import nullthrows from 'nullthrows';
import * as React from 'react';
import {createRef} from 'react';

const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'];

Expand Down Expand Up @@ -76,9 +77,7 @@ class DrawerLayoutAndroid

// $FlowFixMe[missing-local-annot]
_nativeRef =
React.createRef<
React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>,
>();
createRef<React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>>();

state: DrawerLayoutAndroidState = {
drawerOpened: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import AccessibilityInfo from '../AccessibilityInfo/AccessibilityInfo';
import View from '../View/View';
import Keyboard from './Keyboard';
import * as React from 'react';
import {createRef} from 'react';

export type KeyboardAvoidingViewProps = $ReadOnly<{
...ViewProps,
Expand Down Expand Up @@ -73,7 +74,7 @@ class KeyboardAvoidingView extends React.Component<
constructor(props: KeyboardAvoidingViewProps) {
super(props);
this.state = {bottom: 0};
this.viewRef = React.createRef();
this.viewRef = createRef();
}

async _relativeKeyboardHeight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import useAndroidRippleForView, {
type PressableAndroidRippleConfig,
} from './useAndroidRippleForView';
import * as React from 'react';
import {useMemo, useRef, useState} from 'react';
import {memo, useMemo, useRef, useState} from 'react';

type ViewStyleProp = React.ElementConfig<typeof View>['style'];

Expand Down Expand Up @@ -334,7 +334,7 @@ function usePressState(forcePressed: boolean): [boolean, (boolean) => void] {
return [pressed || forcePressed, setPressed];
}

const MemoedPressable = React.memo(Pressable);
const MemoedPressable = memo(Pressable);
MemoedPressable.displayName = 'Pressable';

export default (MemoedPressable: component(
Expand Down
Loading
Loading