Skip to content

Commit 0094885

Browse files
committed
revert hiding style
1 parent d25fef9 commit 0094885

2 files changed

Lines changed: 0 additions & 89 deletions

File tree

src/__tests__/render.test.tsx

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,6 @@ import { Text, View } from 'react-native';
44
import { render, screen } from '..';
55
import { _console, logger } from '../helpers/logger';
66

7-
function MaybeSuspend({
8-
children,
9-
promise,
10-
suspend,
11-
}: {
12-
children: React.ReactNode;
13-
promise: Promise<unknown>;
14-
suspend: boolean;
15-
}) {
16-
if (suspend) {
17-
React.use(promise);
18-
}
19-
20-
return children;
21-
}
22-
237
test('renders a simple component', async () => {
248
const TestComponent = () => (
259
<View testID="container">
@@ -93,64 +77,6 @@ describe('render options', () => {
9377
});
9478
});
9579

96-
describe('hidden instance props', () => {
97-
test('sets hidden suspended elements with no style to display none', async () => {
98-
const promise = new Promise<unknown>(() => {});
99-
100-
function TestComponent({ suspend }: { suspend: boolean }) {
101-
return (
102-
<React.Suspense fallback={<Text>Loading...</Text>}>
103-
<MaybeSuspend promise={promise} suspend={suspend}>
104-
<View testID="hidden-target">
105-
<Text>Ready</Text>
106-
</View>
107-
</MaybeSuspend>
108-
</React.Suspense>
109-
);
110-
}
111-
112-
await render(<TestComponent suspend={false} />);
113-
114-
expect(screen.getByText('Ready')).toBeOnTheScreen();
115-
116-
await screen.rerender(<TestComponent suspend />);
117-
118-
expect(screen.getByText('Loading...')).toBeOnTheScreen();
119-
expect(
120-
screen.getByTestId('hidden-target', { includeHiddenElements: true }).props.style,
121-
).toEqual({
122-
display: 'none',
123-
});
124-
});
125-
126-
test('appends display none when suspending an element with existing style', async () => {
127-
const promise = new Promise<unknown>(() => {});
128-
129-
function TestComponent({ suspend }: { suspend: boolean }) {
130-
return (
131-
<React.Suspense fallback={<Text>Loading...</Text>}>
132-
<MaybeSuspend promise={promise} suspend={suspend}>
133-
<View style={{ opacity: 0.5 }} testID="hidden-target">
134-
<Text>Ready</Text>
135-
</View>
136-
</MaybeSuspend>
137-
</React.Suspense>
138-
);
139-
}
140-
141-
await render(<TestComponent suspend={false} />);
142-
143-
expect(screen.getByText('Ready')).toBeOnTheScreen();
144-
145-
await screen.rerender(<TestComponent suspend />);
146-
147-
expect(screen.getByText('Loading...')).toBeOnTheScreen();
148-
expect(
149-
screen.getByTestId('hidden-target', { includeHiddenElements: true }).props.style,
150-
).toEqual([{ opacity: 0.5 }, { display: 'none' }]);
151-
});
152-
});
153-
15480
describe('component rendering', () => {
15581
test('render accepts RCTText component', async () => {
15682
await render(React.createElement('RCTText', { testID: 'text' }, 'Hello'));

src/render.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import type { StyleProp } from 'react-native';
32
import {
43
createRoot,
54
type HostElement,
@@ -40,10 +39,6 @@ export async function render<T>(element: React.ReactElement<T>, options: RenderO
4039
const rendererOptions: RootOptions = {
4140
textComponentTypes: HOST_TEXT_NAMES,
4241
publicTextComponentTypes: ['Text'],
43-
transformHiddenInstanceProps: ({ props }) => ({
44-
...props,
45-
style: withHiddenStyle(props.style as StyleProp<StyleLike>),
46-
}),
4742
};
4843

4944
const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);
@@ -122,13 +117,3 @@ function makeDebug(renderer: Root): DebugFunction {
122117
}
123118
return debugImpl;
124119
}
125-
126-
type StyleLike = Record<string, unknown>;
127-
128-
function withHiddenStyle(style: StyleProp<StyleLike>): StyleProp<StyleLike> {
129-
if (style == null) {
130-
return { display: 'none' };
131-
}
132-
133-
return [style, { display: 'none' }];
134-
}

0 commit comments

Comments
 (0)