1.0.1 ā€¢ Published 5 years ago

react-decoy v1.0.1

Weekly downloads
2
License
Unlicense
Repository
github
Last release
5 years ago

React Decoy Demo

Table of contents

Getting started

npm install react-decoy
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import { Decoy } from 'react-decoy';

function ClickCounter() {
  const [count, setCount] = useState(0);
  const increment = () => setCount(count + 1);

  return (
    <p>
      <button onClick={increment}>ā†“</button>
      <code>{` = ${count}`}</code>
    </p>
  );
}

function App() {
  const [isActive, setIsActive] = useState(false);
  const toggle = () => setIsActive(!isActive);

  return (
    <div>
      <Decoy active={isActive}>
        <ClickCounter />
        <ClickCounter />
        <ClickCounter />
      </Decoy>
      <button onClick={toggle}>
        {`${isActive ? 'Dea' : 'A'}ctivate Decoy`}
      </button>
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById('root'));

About the project

Credits

  • Icon based on "Prop" by Luis Prado from the Noun Project