React 18 and Vite (#4510)
This commit is contained in:
parent
1bb1b13f6d
commit
21613fa602
244 changed files with 4547 additions and 8933 deletions
|
@ -1,21 +1,23 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import type { ComponentType } from 'react';
|
||||
import { Suspense, useMemo } from 'react';
|
||||
|
||||
import features from './index';
|
||||
import { getObjectKeys } from '@/lib/objects';
|
||||
|
||||
type ListItems = [string, React.ComponentType][];
|
||||
type ListItems = [string, ComponentType][];
|
||||
|
||||
export default ({ enabled }: { enabled: string[] }) => {
|
||||
const mapped: ListItems = useMemo(() => {
|
||||
return getObjectKeys(features)
|
||||
.filter((key) => enabled.map((v) => v.toLowerCase()).includes(key.toLowerCase()))
|
||||
.reduce((arr, key) => [...arr, [key, features[key]]], [] as ListItems);
|
||||
.filter(key => enabled.map(v => v.toLowerCase()).includes(key.toLowerCase()))
|
||||
.reduce((arr, key) => [...arr, [key, features[key]]] as ListItems, [] as ListItems);
|
||||
}, [enabled]);
|
||||
|
||||
return (
|
||||
<React.Suspense fallback={null}>
|
||||
<Suspense fallback={null}>
|
||||
{mapped.map(([key, Component]) => (
|
||||
<Component key={key} />
|
||||
))}
|
||||
</React.Suspense>
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue