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, [||]));