react-context-form-select
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

React Context Form Select

react-select integration with react-context-form

Usage

import * as React from "react";
import { Form, FormGroup, SubmitButton } from "react-context-form";
import { Select } from "react-context-form-select";
import { Options } from "react-select";
import { instantiateTestModel } from "./test";

export enum Role = {
    admin: "Admin",
    user: "User",
}  

class RoleSelect extends Select<Role> {};

const options: Options<Role> = Object.values(Role).map((value: string) => return {label: value, value: value});

export const Form: React.SFC<{}> = () => (
    <Form instantiate={instantiateTestModel}>
        <FormGroup name="role">
            <RoleSelect options={options}>
        </FormGroup>
        <SubmitButton loadingComponent={<span>Loading...</span>}>Send</SubmitButton>
    </Form>
)

TODO

  • Tests

License

MIT

Package Sidebar

Install

npm i react-context-form-select

Weekly Downloads

3

Version

1.2.2

License

MIT

Unpacked Size

53.6 kB

Total Files

29

Last publish

Collaborators

  • horat1us