Skip to content

Commit 0b4a968

Browse files
committed
fix: skeleton cannot dispaly without children
1 parent a67c0d2 commit 0b4a968

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

components/skeleton/Skeleton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const Skeleton = (props: SkeletonProps) => {
161161
</div>
162162
);
163163
}
164-
return children as React.ReactElement;
164+
return children ? children as React.ReactElement : null;
165165
};
166166

167167
Skeleton.defaultProps = {

components/skeleton/__tests__/index.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('Skeleton', () => {
3434
expect(wrapperSmall.render()).toMatchSnapshot();
3535
});
3636

37+
it('should display without children', () => {
38+
const wrapper = mount(<Skeleton loading={false}></Skeleton>);
39+
expect(wrapper.render()).toMatchSnapshot();
40+
});
41+
3742
it('should display children', () => {
3843
const wrapper = mount(<Skeleton loading={false}>{[1, 2, 3]}</Skeleton>);
3944
expect(wrapper.text()).toBe('123');

0 commit comments

Comments
 (0)