JSPM

react-random-slot-machine

0.0.7
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q77162F
  • License MIT

Easily create slot machine in react

Package Exports

  • react-random-slot-machine
  • react-random-slot-machine/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-random-slot-machine) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version

react-random-slot-machine

The library provides reactive slot machine components.
Insert the desired item using props into the component and receive the result of the slot machine.

Table of contents

Installation

To install and set up the library, run:

$ npm install react-random-slot-machine

Or if you prefer using Yarn:

$ yarn add react-random-slot-machine

Usage

Example

import { SlotMachine } from "react-random-slot-machine";

const feelingArr = [
  {
    id: 0,
    img: <img src="#" alt="image" />,
    name: "JOY",
    value: "joy",
  },
  {
    id: 1,
    img: <img src="#" alt="image" />,
    name: "SAD",
    value: "sad",
  },
];

const App: React.FC = () => {
  const result = (resultArr: string[]) => {
    console.log(resultArr);
  };

  return (
    <div>
      <SlotMachine
        firstList={feelingArr}
        secondList={feelingArr}
        thirdList={feelingArr}
        resultToParams={result}
      />
    </div>
  );
};

parameter

  • firstList, secondList, thirdList:

    // id is for indexing
    // insert item into img with ReactNode type
    // name is shown under the img item in slot machine
    // value is return value
    itemList: {id: number, img: React.ReactNode, name?: string, value: string}
  • resultToParams:

    // result will receive to parameter
    resultToParams: (resultArr: Array<string>) => void;

Example Images

example

Authors

License

MIT License