🤖 Merge PR #47086 [react-scrollspy] Fix type definitions for onUpdate prop by @hueter

This commit is contained in:
Michael Hueter 2020-08-27 13:15:08 -07:00 committed by GitHub
parent cef64f0170
commit 3873cd380b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -29,7 +29,7 @@ export interface ScrollspyProps {
rootEl?: string;
// Function to be executed when the active item has been updated
onUpdate?: (item: string) => void;
onUpdate?: (item: HTMLElement) => void;
// ClassName attribute to be passed to the generated <ul /> element
className?: string;

View File

@ -12,10 +12,16 @@ function TestComponent() {
<section id="section-3">section 3</section>
</div>
<Scrollspy items={items} currentClassName="is-current">
<li><a href="#section-1">section 1</a></li>
<li><a href="#section-2">section 2</a></li>
<li><a href="#section-3">section 3</a></li>
<Scrollspy items={items} currentClassName="is-current" onUpdate={el => console.log(el.id)}>
<li>
<a href="#section-1">section 1</a>
</li>
<li>
<a href="#section-2">section 2</a>
</li>
<li>
<a href="#section-3">section 3</a>
</li>
</Scrollspy>
</div>
);