Skip to content

Commit 073a5b7

Browse files
authored
Fixes #139. Add a static class name to outer div (#147)
Fixes #139. Add a static class name to outer div
2 parents dfe6acc + cc6b82e commit 073a5b7

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ node_modules
77
dist
88
.vscode
99
storybook-static/
10-
coverage/
10+
coverage/
11+
yarn-error.log

src/__tests__/index.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,21 @@ describe('React Infinite Scroll Component', () => {
137137
);
138138
expect(queryByText('Reached end.')).toBeTruthy();
139139
});
140+
141+
it('adds a classname to the outer div', () => {
142+
const { container } = render(
143+
<InfiniteScroll
144+
hasMore={true}
145+
dataLength={10}
146+
next={() => {}}
147+
loader={<div>Loading...</div>}
148+
>
149+
<div />
150+
</InfiniteScroll>
151+
);
152+
const outerDiv = container.getElementsByClassName(
153+
'infinite-scroll-component__outerdiv'
154+
);
155+
expect(outerDiv.length).toBeTruthy();
156+
});
140157
});

src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,10 @@ export default class InfiniteScroll extends Component<Props, State> {
307307
? { overflow: 'auto' }
308308
: {};
309309
return (
310-
<div style={outerDivStyle}>
310+
<div
311+
style={outerDivStyle}
312+
className="infinite-scroll-component__outerdiv"
313+
>
311314
<div
312315
className={`infinite-scroll-component ${this.props.className || ''}`}
313316
ref={(infScroll: HTMLDivElement) => (this._infScroll = infScroll)}

0 commit comments

Comments
 (0)