rax-polyfill-ref

1.0.13 • Public • Published

rax-polyfill-ref

Polyfill for Rax new ref api

Support

>= rax@0.6.5

Usage

import { createRef, forwardRef } from 'rax-polyfill-ref';
const ref = createRef();

function App() {
  return (
    <div>
      <input ref={ref} />
      <button onClick={() => ref.current.focus()}>click</button>
    </div>
  );
}

// forwardRef

const ref = createRef();

const Input = forwardRef((props, ref) => {
  return <input ref={ref} />
});

const App = () => {
  return (
    <div>
      <Input ref={ref} />
      <button onClick={() => ref.current.focus()}>click</button>
    </div>
  );
};

For more usage, see https://reactjs.org/docs/refs-and-the-dom.html#creating-refs

Others

You can use it with rax-polyfill-context and rax-polyfill-hooks

/rax-polyfill-ref/

    Package Sidebar

    Install

    npm i rax-polyfill-ref

    Weekly Downloads

    2

    Version

    1.0.13

    License

    MIT

    Unpacked Size

    5.12 kB

    Total Files

    4

    Last publish

    Collaborators

    • kingback