Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose LogViewerProps #68

Merged
merged 1 commit into from
Jun 27, 2024
Merged

expose LogViewerProps #68

merged 1 commit into from
Jun 27, 2024

Conversation

paul-vd
Copy link
Contributor

@paul-vd paul-vd commented Jun 9, 2024

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;
};

Allows to reuse the props in extracted logic.
@nicolethoen nicolethoen merged commit e46d403 into patternfly:main Jun 27, 2024
7 checks passed
Copy link

🎉 This PR is included in version 5.2.0-prerelease.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants