bs react admin
1.0.0
用于反应管理的 BuckleScript 绑定。
?这是一个 WIP,尚未支持所有内容。 ?
如果您发现缺少任何内容,请随时创建问题或 PR。
此外,许多类型都过于宽松,试图让 React-admin 与 ReasonML 项目一起工作。希望这些类型在未来的版本中会更加严格。
npm install --save @ctbucha/bs-react-admin
然后将@ctbucha/bs-react-admin添加到bsconfig.json中的bs-dependencies中:
{
...
"bs-dependencies": ["@ctbucha/bs-react-admin"]
}/* App.re */let component = ReasonReact.statelessComponent("App");let myHttpClient = (url, _params) => { let headersDict = Js.Dict.empty();
Js.Dict.set(headersDict, "接受", "application/json");
让标题=
headersDict |> Fetch.HeadersInit.makeWithDict |> Fetch.Headers.makeWithInit;
BsReactAdmin.FetchUtils.headersSet(params, headers);
BsReactAdmin.FetchUtils.fetchJson(url, params);};让 dataProvider =
BsRaDataJsonServer.getRaDataJsonServer(
〜apiUrl =“http://jsonplaceholder.typicode.com”,〜httpClient = myHttpClient,(),
);让 make = _children => {
...成分,
渲染:_self => BsReactAdmin。(
<div>
<管理数据提供者>
<资源名称=“帖子”列表= PostList.toReactJs />
</管理员>
</div>
),
}; /* PostList.re */let component = ReasonReact.statelessComponent("PostList");let make = (props, _children) => {
...成分,
渲染:_self => BsReactAdmin。(
<div>
<列出道具>
<数据网格>
<TextField 源=“id”/>
<TextField 源=“标题”/>
<TextField 源=“正文”/>
</数据网格>
</列表>
</div>
),};/* 需要将其作为 ReactJS 组件而不是 ReasonReact * 组件传递给 Resource,因为 React-admin 将其作为 ReactJS 组件处理。 */让toReactJs =
ReasonReact.wrapReasonForJs(~component, jsProps => make(jsProps, [||]));