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

@ctbucha/bs-react-admin

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ctbucha/bs-react-admin

BuckleScript bindings for react-admin

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

bs-react-admin

BuckleScript bindings for react-admin.

Status

🚧 This is a WIP, not everything is supported yet. 🚧

Feel free to create an issue or PR if you find anything missing.

Also, many of the types are overly permissive in an attempt to just get react-admin to work with ReasonML projects. Hopefully, these types will be much stricter in future releases.

Installation

npm install --save @ctbucha/bs-react-admin

Then add @ctbucha/bs-react-admin to bs-dependencies in your bsconfig.json:

{
  ...
  "bs-dependencies": ["@ctbucha/bs-react-admin"]
}

Usage

/* App.re */
let component = ReasonReact.statelessComponent("App");

let myHttpClient = (url, _params) => {
  let headersDict = Js.Dict.empty();
  Js.Dict.set(headersDict, "Accept", "application/json");

  let headers = 
    headersDict |> Fetch.HeadersInit.makeWithDict |> Fetch.Headers.makeWithInit;

  BsReactAdmin.FetchUtils.headersSet(params, headers);

  BsReactAdmin.FetchUtils.fetchJson(url, params);
};

let dataProvider = 
  BsRaDataJsonServer.getRaDataJsonServer(
    ~apiUrl="http://jsonplaceholder.typicode.com",
    ~httpClient=myHttpClient,
    (),
  );

let make = _children => { 
  ...component,
  render: _self => 
    BsReactAdmin.(
      <div>
        <Admin dataProvider>
          <Resource name="posts" list=PostList.toReactJs />
        </Admin>
      </div>
    ),  
    };
/* PostList.re */
let component = ReasonReact.statelessComponent("PostList");

let make = (props, _children) => { 
  ...component,
  render: _self => 
    BsReactAdmin.(
      <div>
        <List props>
          <Datagrid>
            <TextField source="id" />
            <TextField source="title" />
            <TextField source="body" />
          </Datagrid>
        </List>
      </div>
    ),
};

/* Need to pass this to Resource as a ReactJS component instead of a ReasonReact
 * component since react-admin handles this as a ReactJS component.
 */
let toReactJs = 
  ReasonReact.wrapReasonForJs(~component, jsProps => make(jsProps, [||]));

Keywords

FAQs

Package last updated on 28 Sep 2018

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