1.0.13 • Published 3 years ago

rax-polyfill-ref v1.0.13

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

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

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

4 years ago

1.0.7

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago