Skip to content

Commit 6c18429

Browse files
committed
Adjust tests that were using string refs for something else
1 parent 990797f commit 6c18429

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

packages/react/src/__tests__/ReactElementJSX-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe('ReactElement.jsx', () => {
221221
class Parent extends React.Component {
222222
render() {
223223
return JSXRuntime.jsx('div', {
224-
children: JSXRuntime.jsx(Child, {ref: 'childElement'}),
224+
children: JSXRuntime.jsx(Child, {ref: React.createRef()}),
225225
});
226226
}
227227
}

packages/react/src/__tests__/ReactJSXElement-test.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,11 @@ describe('ReactJSXElement', () => {
7878
});
7979

8080
it('extracts key and ref from the rest of the props', () => {
81-
const element = (
82-
<Component
83-
key="12"
84-
ref={current => {
85-
this.refs['34'] = current;
86-
}}
87-
foo="56"
88-
/>
89-
);
81+
const ref = React.createRef();
82+
const element = <Component key="12" ref={ref} foo="56" />;
9083
expect(element.type).toBe(Component);
9184
expect(element.key).toBe('12');
92-
expect(element.ref).toBe('34');
85+
expect(element.ref).toBe(ref);
9386
const expectation = {foo: '56'};
9487
Object.freeze(expectation);
9588
expect(element.props).toEqual(expectation);

packages/react/src/__tests__/ReactProfilerDevToolsIntegration-test.internal.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ describe('ReactProfiler DevTools integration', () => {
101101
);
102102
});
103103

104+
// FIXME: What would throw in a host root apart from string refs without owner?
105+
// @gate !warnAboutStringRefs
104106
it('should reset the fiber stack correctly after an error when profiling host roots', () => {
105107
Scheduler.unstable_advanceTime(20);
106108

@@ -114,10 +116,7 @@ describe('ReactProfiler DevTools integration', () => {
114116

115117
expect(() => {
116118
rendered.update(
117-
<div
118-
ref={current => {
119-
this.refs['this-will-cause-an-error'] = current;
120-
}}>
119+
<div ref="this-will-cause-an-error">
121120
<AdvanceTime byAmount={3} />
122121
</div>,
123122
);

0 commit comments

Comments
 (0)