Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bs-react-dropzone

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bs-react-dropzone

ReasonML bindings for react-dropzone library

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

bs-react-dropzone

Build Status dependencies Status devDependencies Status peerDependencies Status Greenkeeper badge

ReasonML bindings for react-dropzone library.

Installation

npm i --save bs-react-dropzone react-dropzone

Then add bs-react-dropzone as a dependency to bsconfig.json.

Usage

[@react.component]
let make = () => {
  <ReactDropzone
    accept={ReactDropzone.Single("application/json")}
    multiple=true
    onDrop={(acceptedFiles, _) =>
      Js.log(("these files were dropped", acceptedFiles))
    }>
    {({getInputProps, getRootProps}) => {
      let inputProps = getInputProps();
      let rootProps = getRootProps();

      <div
        onBlur={rootProps.onBlur}
        onDragEnter={rootProps.onDragEnter}
        onDragLeave={rootProps.onDragLeave}
        onDragOver={rootProps.onDragOver}
        onDragStart={rootProps.onDragStart}
        onDrop={rootProps.onDrop}
        onFocus={rootProps.onFocus}
        onKeyDown={rootProps.onKeyDown}
        ref={ReactDOMRe.Ref.callbackDomRef(rootProps.ref)}
        tabIndex={rootProps.tabIndex}>
        <div> {"Drop files here" |> React.string} </div>
        <input
          autoComplete={inputProps.autoComplete}
          onChange={inputProps.onChange}
          onClick={inputProps.onClick}
          ref={ReactDOMRe.Ref.callbackDomRef(inputProps.ref)}
          style={inputProps.style}
          tabIndex={inputProps.tabIndex}
          type_={inputProps.type_}
          multiple={inputProps.multiple}
        />
      </div>;
    }}
  </ReactDropzone>;
};

JSX 2

The package provides fallback for projects using older version of JSX syntax.

let component = ReasonReact.statelessComponent("Demo");

let make = () => {
  ...component,
  render: (_self) => {
    <ReactDropzone.Jsx2
      accept={ReactDropzone.Single("application/json")}
      multiple=true
      onDrop={(acceptedFiles, _) =>
        Js.log(("these files were dropped", acceptedFiles))
      }>
      ...{({getInputProps, getRootProps}) => {
        let inputProps = getInputProps();
        let rootProps = getRootProps();

        <div
          onBlur={rootProps.onBlur}
          onDragEnter={rootProps.onDragEnter}
          onDragLeave={rootProps.onDragLeave}
          onDragOver={rootProps.onDragOver}
          onDragStart={rootProps.onDragStart}
          onDrop={rootProps.onDrop}
          onFocus={rootProps.onFocus}
          onKeyDown={rootProps.onKeyDown}
          ref={rootProps.ref}
          tabIndex={rootProps.tabIndex}>
          <div> {"Drop files here" |> React.string} </div>
          <input
            autoComplete={inputProps.autoComplete}
            onChange={inputProps.onChange}
            onClick={inputProps.onClick}
            ref={inputProps.ref}
            style={inputProps.style}
            tabIndex={inputProps.tabIndex}
            type_={inputProps.type_}
            multiple={inputProps.multiple}
          />
        </div>;
      }}
    </ReactDropzone.Jsx2>;
  }
};

Hooks

Hooks are not supported right now. There is an issue open for that. PRs are welcome!

Keywords

FAQs

Package last updated on 02 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc