React headless components - Quickly build robust react apps
- no UI dependencies
- Minimal bootstrap implementation
- Typescript, all props typed
yarn add @nexys/headless
All components fitting ui-type.ts
must be created for a particular design system.
Then instantiate list-super
with the created UI components
see example here
Create a request function that extends https://github.com/nexys-system/react-headless/blob/master/src/lib/request/fetch.ts#L4
below an untested implementation example:
const request = <A, B = any>(
url: string,
method:Method = "GET",
data?: B
): Promise<A> => {
try {
return fetchJSON(url, {method, data});
} catch (err) {
if(err.message) {
throw Error(err)
}
const {status, data}:{status:number, data?:any} = err;
if (status === 401) {
// user unauthenticated, redirect to login?
}
if (status === 403) {
// not enough permissions, display toast
}
if (status === 500) {
// todo
}
if (status === 400) {
return Promise.reject(data)
}
}
}