patternfly / react-log-viewer

MIT License
22 stars 14 forks source link

expose `LogViewerProps` #68

Closed paul-vd closed 5 months ago

paul-vd commented 5 months ago

What?

This allows to re-use the props for extracted logic

Example

import { LogViewer, LogViewerProps } from "@patternfly/react-log-viewer";

const useScrollToRow = (logs: LogViewerProps["data"] = []) => {
  const [isUserScrolling, setIsUserScrolling] = useState(false);

  const onScroll:LogViewerProps["onScroll"] = (event) => { // 👈 here we can no get the event props without having to re-define them
    if (event.scrollOffsetToBottom < 30) {
      setIsUserScrolling(false);
    } else {
      setIsUserScrolling(true);
    }
  }

  return [
    isUserScrolling ? undefined : logs.length - 1,
    onScroll,
  ] as const;
};
github-actions[bot] commented 4 months ago

:tada: This PR is included in version 5.2.0-prerelease.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: