DefinitelyTyped/types/react-scrollspy/index.d.ts
Michael Macnair 76a0f7d9e9 react-scrollspy: componentTag can take components (#37977)
Its proptypes defintion is:
 componentTag: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
But it's used like:
  <componentTag className={ itemClass } style={ style }>
Which makes it a component not any old function.
2019-09-03 13:08:13 -07:00

42 lines
1.4 KiB
TypeScript

// Type definitions for react-scrollspy 3.3
// Project: https://github.com/makotot/react-scrollspy
// Definitions by: Zhang Yi Jiang <https://github.com/ZhangYiJiang>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
export interface ScrollspyProps {
// Array of target element IDs
items: ReadonlyArray<string>;
// Class name that apply to the navigation element paired with the content element in viewport
currentClassName: string;
// Class name that apply to the navigation elements that have been scrolled past
scrolledPastClassName?: string;
// HTML tag for Scrollspy component if you want to use other than ul
componentTag?: string | React.ComponentType;
// Style attribute to be passed to the generated <ul /> element
style?: React.CSSProperties;
// Offset value that adjusts to determine the elements are in the viewport
offset?: number;
// Selector for the element of scrollable container that can be used with querySelector
rootEl?: string;
// Function to be executed when the active item has been updated
onUpdate?: (item: string) => void;
}
export default class Scrollspy extends React.Component<ScrollspyProps> {
// Add event listener of scrollspy.
onEvent(): void;
// Remove event listener of scrollspy.
offEvent(): void;
}