0.0.2 • Published 6 years ago

react-create-variant v0.0.2

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

React Create Variant

Create variants of a react component with predefined props.

Installation

npm install react-create-variant

Usage

// Buttons.js
import React from 'react';
import { createVariant } from 'react-create-variant';

const Button = props => <button {...props} />;

export const ResetButton = createVariant(Button, {
  type: 'reset',
  className: 'btn btn-secondary',
});
export const SubmitButton = createVariant(Button, {
  type: 'submit',
  className: 'btn btn-primary',
});

// Form.js
import React from 'react';
import { ResetButton, SubmitButton } from 'react';

const Form = () => (
  <form>
    ...
    <ResetButton />
    <SubmitButton />
  </form>
);