Skip to content

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
@github-actions
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants