Skip to content

@patternfly/[email protected]

Compare
Choose a tag to compare
@github-actions github-actions released this 05 Jul 10:22
· 237 commits to main since this release
99e4081

Minor Changes

  • c4170a5: PatternFly elements are now available wrapped in React components. While it was
    always possible to use PatternFly elements (or any other custom elements) in
    React apps, this release makes it easier to integrate them into React without
    the need for cumbersome workarounds to React's poor HTML and DOM support.

    Before:

    import { useEffect, useState, useRef } from "react";
    import "@patternfly/elements/pf-switch/pf-switch.js";
    
    function App() {
      const [checked, setChecked] = useState(false);
      const switchRef = useRef(null);
      useEffect(() => {
        switchRef.current.checked = checked;
      }, [switchRef.current, checked]);
      useEffect(() => {
        switchRef.current.addEventListener("change", () =>
          setChecked(switchRef.current.checked)
        );
      }, [switchRef.current]);
      return (
        <>
          <pf-switch ref={switchRef}></pf-switch>
        </>
      );
    }

    After:

    import { useState } from "react";
    import { Switch } from "@patternfly/elements/react/pf-switch/pf-switch.js";
    
    function App() {
      const [checked, setChecked] = useState(false);
      return (
        <>
          <Switch
            checked={checked}
            onChange={({ target }) => setChecked(target.checked)}
          />
        </>
      );
    }

Patch Changes