bhr / react-mirror

🪞 Create synchronized replicas of a React DOM element

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Mirror

⚛️

NPM badge Dependabot badge Dependencies Build Status Coverage Status

Create synchronized replicas of a React DOM element

Usage

See equivalent uses of the hook and component below.

useMirror hook

import { useMirror } from 'react-mirror';

function App() {
  const [ref, reflection] = useMirror({ className: 'mirror-frame' });
  return (
    <>
      <div ref={ref} />
      {reflection}
    <>
  );
}

<Mirror /> component

import React from 'react';
import { Mirror } from 'react-mirror';

function App() {
  const [reflect, setReflect] = React.useState(null);
  return (
    <>
      <div ref={setReflect} />
      <Mirror reflect={reflect} className='mirror-frame'/>
    <>
  );
}

Demos

Using Portals

About

🪞 Create synchronized replicas of a React DOM element

License:The Unlicense


Languages

Language:TypeScript 96.9%Language:Shell 3.1%