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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @format
*/

import type {ImageProps} from '../../Image/ImageProps';
import type {AnimatedComponentType} from '../createAnimatedComponent';

import Image from '../../Image/Image';
Expand All @@ -18,6 +19,6 @@ export default createAnimatedComponent<
$FlowFixMe,
React.ElementRef<typeof Image>,
>(Image as $FlowFixMe) as AnimatedComponentType<
React.ElementConfig<typeof Image>,
ImageProps,
React.ElementRef<typeof Image>,
>;
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const AnimatedScrollViewWithInvertedRefreshControl =
...props
}: {
ref?: React.RefSetter<AnimatedScrollViewInstance>,
...React.ElementConfig<typeof ScrollView>,
...React.ComponentProps<typeof ScrollView>,
// $FlowFixMe[unclear-type] Same Flow type as `refreshControl` in ScrollView
refreshControl: React.MixedElement,
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {useMemo} from 'react';
type Nullable = void | null;
type Primitive = string | number | boolean | symbol | void;
type Builtin = (...ReadonlyArray<empty>) => unknown | Date | Error | RegExp;
type ComponentProps<T> =
T extends React.ComponentType<infer Props> ? Props : empty;

export type WithAnimatedValue<out T> = T extends Builtin | Nullable
? T
Expand Down Expand Up @@ -98,7 +100,7 @@ export default function createAnimatedComponent<
>(
Component: TInstance,
): AnimatedComponentType<
Readonly<React.ElementConfig<TInstance>>,
Readonly<ComponentProps<TInstance>>,
React.ElementRef<TInstance>,
> {
return unstable_createAnimatedComponentWithAllowlist(Component, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function Pressable({
ariaLive === 'off' ? 'none' : (ariaLive ?? props.accessibilityLiveRegion);

const accessibilityLabel = ariaLabel ?? props.accessibilityLabel;
const restPropsWithDefaults: React.ElementConfig<typeof View> = {
const restPropsWithDefaults: React.ComponentProps<typeof View> = {
...restProps,
...android_rippleConfig?.viewProps,
accessible: accessible !== false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ const autoCompleteWebToTextContentTypeMap = {
*/
const TextInput: component(
ref?: React.RefSetter<TextInputInstance>,
...props: React.ElementConfig<typeof InternalTextInput>
...props: React.ComponentProps<typeof InternalTextInput>
) = function TextInput({
ref: forwardedRef,
allowFontScaling = true,
Expand All @@ -916,7 +916,7 @@ const TextInput: component(
...restProps
}: {
ref?: React.RefSetter<TextInputInstance>,
...React.ElementConfig<typeof InternalTextInput>,
...React.ComponentProps<typeof InternalTextInput>,
}) {
return (
<InternalTextInput
Expand Down
18 changes: 6 additions & 12 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3ce9599aceb36dd1f09ded3db3332daa>>
* @generated SignedSource<<83faf91fab56f9b954a3bb7cfdef59e1>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand All @@ -24,10 +24,7 @@
import * as React from "react"
declare const $$AnimatedFlatList: typeof AnimatedFlatList_default
declare const $$AnimatedImage: AnimatedComponentType<
React.JSX.LibraryManagedAttributes<
typeof Image,
React.ComponentProps<typeof Image>
>,
ImageProps,
React.ComponentRef<typeof Image>
>
declare const $$AnimatedImplementation: {
Expand Down Expand Up @@ -1748,6 +1745,8 @@ declare type ColorListenerCallback = (value: ColorValue) => unknown
declare type ColorSchemeName = "dark" | "light"
declare type ColorSchemeOverride = "auto" | "dark" | "light" | "unspecified"
declare type ColorValue = ____ColorValue_Internal
declare type ComponentProps<T> =
T extends React.ComponentType<infer Props> ? Props : never
declare type ComponentProvider = () => React.ComponentType<any>
declare type ComponentProviderInstrumentationHook = (
component_: ComponentProvider,
Expand Down Expand Up @@ -1799,12 +1798,7 @@ declare function createAnimatedComponent_default<
>(
Component: TInstance,
): AnimatedComponentType<
Readonly<
React.JSX.LibraryManagedAttributes<
TInstance,
React.ComponentProps<TInstance>
>
>,
Readonly<ComponentProps<TInstance>>,
React.ComponentRef<TInstance>
>
declare function createLayoutAnimation(
Expand Down Expand Up @@ -5771,7 +5765,7 @@ export {
AlertOptions, // 8a116d2a
AlertType, // 5ab91217
AndroidKeyboardEvent, // e03becc8
Animated, // 990adcb6
Animated, // ed4648e6
AppConfig, // 35c0ca70
AppRegistry, // edec2a30
AppState, // 12012be5
Expand Down
2 changes: 1 addition & 1 deletion packages/rn-tester/js/components/RNTPressableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as React from 'react';
import {useContext} from 'react';
import {Pressable, StyleSheet, Text, View} from 'react-native';

type ViewStyleProp = React.ElementConfig<typeof View>['style'];
type ViewStyleProp = React.ComponentProps<typeof View>['style'];
type Props = {
accessibilityLabel?: ?string,
testID?: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import * as React from 'react';
import {useContext} from 'react';
import {StyleSheet, Switch, Text, View} from 'react-native';

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

type Props = {
value: boolean,
onValueChange: React.ElementConfig<typeof Switch>['onValueChange'],
onValueChange: React.ComponentProps<typeof Switch>['onValueChange'],
style?: ?ViewStyleProp,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Item = ({item, separators}: ListRenderItemInfo<string>) => {
};

type Props = Readonly<{
exampleProps: Partial<React.ElementConfig<typeof FlatList>>,
exampleProps: Partial<React.ComponentProps<typeof FlatList>>,
exampleTestID?: ?string,
onTest?: ?() => void,
testLabel?: ?string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Item = ({item, section, separators}) => {

type Props = Readonly<{
// $FlowFixMe[unclear-type]
exampleProps: Partial<React.ElementConfig<typeof SectionList<any>>>,
exampleProps: Partial<React.ComponentProps<typeof SectionList<any>>>,
exampleTestID?: ?string,
onTest?: ?() => void,
testLabel?: ?string,
Expand Down
4 changes: 2 additions & 2 deletions packages/rn-tester/js/examples/TextInput/ExampleTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {StyleSheet, TextInput} from 'react-native';

const ExampleTextInput: component(
ref?: React.RefSetter<null | React.ElementRef<typeof TextInput>>,
...props: Omit<React.ElementConfig<typeof TextInput>, 'ref'>
...props: Omit<React.ComponentProps<typeof TextInput>, 'ref'>
) = ({
ref,
...props
}: {
ref?: React.RefSetter<null | React.ElementRef<typeof TextInput>>,
...React.ElementConfig<typeof TextInput>,
...React.ComponentProps<typeof TextInput>,
}) => {
const theme = useContext(RNTesterThemeContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ function DynamicContentWidth() {
function AutogrowingTextInputExample({
style,
...props
}: React.ElementConfig<typeof TextInput>) {
}: React.ComponentProps<typeof TextInput>) {
const [multiline, setMultiline] = useState(true);
const [fullWidth, setFullWidth] = useState(true);
const [text, setText] = useState('');
Expand Down
Loading