@/store#defaultState TypeScript Examples
The following examples show how to use
@/store#defaultState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: drip-table-generator.tsx From drip-table with MIT License | 5 votes |
Container = < RecordType extends DripTableRecordTypeBase = DripTableRecordTypeBase, ExtraOptions extends DripTableExtraOptions = DripTableExtraOptions, >(props: DripTableGeneratorProps<RecordType, ExtraOptions>, ref: React.ForwardedRef<DripTableGeneratorHandler>) => { if (props.schema && props.schema.columns.some(c => c.component || c.options)) { props = { ...props, schema: { ...props.schema, columns: props.schema.columns.map((column) => { // 兼容旧版本数据 if ('ui:type' in column || 'ui:props' in column) { const key = column.key; if ('ui:type' in column) { console.warn(`[DripTable] Column ${key} "ui:type" is deprecated, please use "component" instead.`); } if ('ui:props' in column) { console.warn(`[DripTable] Column ${key} "ui:props" is deprecated, please use "options" instead.`); } return { ...Object.fromEntries(Object.entries(column).filter(([k]) => k !== 'ui:type' && k !== 'ui:props')), options: column['ui:props'] || column.options || void 0, component: column['ui:type'] || column.component, } as typeof column; } return column; }), }, }; } const wrapper = useRef(null); const initialState = defaultState(); const store = useState(initialState); const context = useTableRoot(props, store, wrapper); useImperativeHandle(ref, () => context); const WrapperRef = forwardRef<GeneratorWrapperHandler, DripTableGeneratorProps<RecordType, ExtraOptions> & { store: GlobalStore }>(Wrapper); return ( <ConfigProvider locale={zhCN}> <Ctx.Provider {...props} value={context}> <WrapperRef ref={wrapper} {...props} store={store} /> </Ctx.Provider> </ConfigProvider> ); }