Skip to content

Commit 53da585

Browse files
miblanchardfacebook-github-bot
authored andcommitted
Fix: Add displayName to ActivityIndicator (#22417)
Summary: Similar to #21950, this adds displayName to `ActivityIndicator`, so it displays the correct component name in snapshots instead of `Component`. Fixes #21937 (a little bit more than it was already fixed). Pull Request resolved: #22417 Differential Revision: D13205376 Pulled By: TheSavior fbshipit-source-id: 21e71d4980d159a1f33d32d83346b48257ec21d4
1 parent b5571cd commit 53da585

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Libraries/Components/ActivityIndicator/ActivityIndicator.js

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const ActivityIndicator = (
112112

113113
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
114114
const ActivityIndicatorWithRef = React.forwardRef(ActivityIndicator);
115+
ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
115116

116117
ActivityIndicatorWithRef.defaultProps = {
117118
animating: true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
* @emails oncall+react_native
9+
*/
10+
11+
'use strict';
12+
13+
const React = require('React');
14+
const ReactTestRenderer = require('react-test-renderer');
15+
const ActivityIndicator = require('ActivityIndicator');
16+
17+
describe('ActivityIndicator', () => {
18+
it('renders correctly', () => {
19+
const instance = ReactTestRenderer.create(
20+
<ActivityIndicator size="large" color="#0000ff" />,
21+
);
22+
23+
expect(instance.toJSON()).toMatchSnapshot();
24+
});
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ActivityIndicator renders correctly 1`] = `
4+
<ActivityIndicator
5+
animating={true}
6+
color="#0000ff"
7+
hidesWhenStopped={true}
8+
size="large"
9+
/>
10+
`;

0 commit comments

Comments
 (0)