Skip to content

cettoana/react-lucky-box

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Lucky Box

🎲 Render random React component from set

npm version license code style: prettier

Example

Go to live example or

Edit react-lucky-box-example

Install

npm install react-lucky-box --save

or

yarn add react-lucky-box

Example

import React, { Component } from 'react'
import LuckyBox from 'react-lucky-box'

const lots = ['apple', 'banana', 'lemon']

class App extends Component {
  render() {
    return (
      <LuckyBox lots={lots}>
        {
          ({ lot, draw }) => (
            <div>
              <div>You got {lot}</div>
              <button onClick={() => draw()}>Redraw</button>
            </div>
          )
        }
      </LuckyBox>
    )
  }
}