docs(changeset): Extra api options, local data options
This commit is contained in:
@@ -3,10 +3,15 @@ import React, { useEffect } from 'react';
|
||||
|
||||
import type { APIOptions } from '../../utils/types';
|
||||
|
||||
import { GoAPIHeaders, type GoAPIOperation } from '../../utils/golang-restapi-v2';
|
||||
import { useGridlerStore } from '../GridlerStore';
|
||||
|
||||
//The computer component does not need to be recalculated on every render, so we use React.memo to prevent unnecessary re-renders.
|
||||
export const GlidlerAPIAdaptorForGoLangv2 = React.memo((props: APIOptions) => {
|
||||
export interface GlidlerAPIAdaptorForGoLangv2Props<T = unknown> extends APIOptions {
|
||||
initialData?: Array<T>;
|
||||
options?: Array<GoAPIOperation>;
|
||||
}
|
||||
|
||||
function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForGoLangv2Props<T>) {
|
||||
const [setStateFN, setState, getState, addError, mounted] = useGridlerStore((s) => [
|
||||
s.setStateFN,
|
||||
s.setState,
|
||||
@@ -49,6 +54,13 @@ export const GlidlerAPIAdaptorForGoLangv2 = React.memo((props: APIOptions) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (props.options && props.options.length > 0) {
|
||||
const optionHeaders = GoAPIHeaders(props.options);
|
||||
for (const oh in optionHeaders) {
|
||||
head.set(oh, optionHeaders[oh]);
|
||||
}
|
||||
}
|
||||
|
||||
const currentRequestIndex = _active_requests?.findIndex((f) => f.page === index) ?? -1;
|
||||
_active_requests?.forEach((r) => {
|
||||
if ((r.page >= 0 && r.page < index - 2) || (index >= 0 && r.page > index + 2)) {
|
||||
@@ -142,6 +154,9 @@ export const GlidlerAPIAdaptorForGoLangv2 = React.memo((props: APIOptions) => {
|
||||
}, [props.url, props.authtoken, mounted, setState]);
|
||||
|
||||
return <></>;
|
||||
});
|
||||
}
|
||||
|
||||
//The computer component does not need to be recalculated on every render, so we use React.memo to prevent unnecessary re-renders.
|
||||
export const GlidlerAPIAdaptorForGoLangv2 = React.memo(_GlidlerAPIAdaptorForGoLangv2);
|
||||
|
||||
GlidlerAPIAdaptorForGoLangv2.displayName = 'Gridler-GlidlerAPIAdaptorForGoLangv2';
|
||||
|
||||
Reference in New Issue
Block a user