Skip to content

Commit 53761c7

Browse files
committed
fix portal, simplify render
FlatList removes components with position: "absolute"
1 parent 97d1225 commit 53761c7

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed

example/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Foo = React.forwardRef<FooHandle, {}>((props, ref) => {
4444

4545
return (
4646
<View {...props}>
47-
<Text>Hello, World!</Text>
47+
<Text>Your component goes here!</Text>
4848
</View>
4949
);
5050
});

src/TestSuite.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ export const useTestSuite = (tests: Test[]) => {
1313
const ref = React.useRef();
1414

1515
React.useEffect(() => {
16-
const render: Render = ({ Component, waitFor, onError }) => {
17-
return new Promise((resolve, reject) => {
16+
const render: Render = ({ Component, waitFor }) => {
17+
return new Promise(resolve => {
1818
const cloneProps = {
1919
ref,
2020
key: Math.random(), // to prevent reusing component across multiple tests
2121
...(waitFor && { [waitFor]: () => resolve(ref.current) }),
22-
...(onError && { [onError]: reject }),
2322
};
2423
const clone = React.cloneElement(Component, cloneProps);
2524

src/components.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import * as React from 'react';
22
import { View, Text, StyleSheet } from 'react-native';
33
import { jasmine } from './types';
44

5-
export const Portal: React.FC = ({ children }) => (
6-
<View style={{ position: 'absolute', opacity: 0 }}>{children}</View>
7-
);
5+
export const Portal: React.FC = ({ children }) => <View>{children}</View>;
86

97
export const Header: React.FC<{ status: string; result: string }> = ({
108
status,

src/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import * as React from 'react';
33
export type Render = <T>({
44
Component,
55
waitFor,
6-
onError,
76
}: {
87
Component: React.ReactElement;
98
waitFor?: string;
10-
onError?: string;
119
}) => Promise<React.MutableRefObject<T>['current']>;
1210

1311
export type Test = (tester: Tester, render: Render) => void;

0 commit comments

Comments
 (0)