Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{() => {
// Now that the network request for data has been triggered, we
// try to initialise the fields. They are Suspense capable, so may
// throw Promises which will be caught by the above
captureSuspensePromises(
fields
.filter(field => field.path !== '_label_')
.map(field => () => field.initCellView())
);
// NOTE: We don't check for isLoading here because we want to
// avoid showing the component when we already
// have (possibly stale) data to show.
// Instead, we show the loader when there's _no data at all_.
if (!items) {
return (
{() => {
const creatable = list.fields
.filter(({ isPrimaryKey }) => !isPrimaryKey)
.filter(({ maybeAccess }) => !!maybeAccess.create);
captureSuspensePromises(creatable.map(field => () => field.initFieldView()));
return creatable.map((field, i) => (
{() => {
let [Field] = field.adminMeta.readViews([field.views.Field]);
let onChange = useCallback(value => {
this.setState(({ item }) => ({
item: {
...item,
[field.path]: value,
},
validationErrors: {},
validationWarnings: {},
}));
}, []);
return useMemo(
() => (
{() => {
captureSuspensePromises(
fields
.filter(field => field.path !== '_label_')
.map(field => () => field.initCellView())
);
return ;
}}