mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fixed a bunch of Lint issues
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// @flow
|
||||
|
||||
import React, {Fragment} from 'react';
|
||||
|
||||
function wrapWithHoc(Component, index) {
|
||||
function HOC() {
|
||||
return <Component />;
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
const displayName = Component.displayName || Component.name;
|
||||
|
||||
HOC.displayName = `withHoc${index}(${displayName})`;
|
||||
return HOC;
|
||||
}
|
||||
|
||||
function wrapWithNested(Component, times) {
|
||||
for (let i = 0; i < times; i++) {
|
||||
Component = wrapWithHoc(Component, i);
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
function Nested() {
|
||||
return <div>Deeply nested div</div>;
|
||||
}
|
||||
|
||||
const DeeplyNested = wrapWithNested(Nested, 100);
|
||||
|
||||
export default function DeeplyNestedComponents() {
|
||||
return (
|
||||
<Fragment>
|
||||
<h1>Deeply nested component</h1>
|
||||
<DeeplyNested />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user