Skip to content

Commit

Permalink
feat(forms): apply dynamic component loader to form app init
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekys committed Feb 29, 2024
1 parent 060ec51 commit 6142b57
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FormConfigProvider } from "./contexts";
import { Container } from "semantic-ui-react";
import { BrowserRouter as Router } from "react-router-dom";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { loadDynamicComponents } from "../util";

import Overridable, {
OverridableContext,
Expand Down Expand Up @@ -36,18 +37,20 @@ export function createFormAppInit({
ContainerComponent = React.Fragment,
defaultComponentOverrides = {},
} = {}) {
const initFormApp = ({ rootEl, ...config }) => {
const initFormApp = async ({ rootEl, ...config }) => {
console.debug("Initializing Formik form app...");
console.debug({...config});

const overridableIdPrefix = config.formConfig.overridableIdPrefix;

const internalComponentDefaults = {};
const dynamicComponents = await loadDynamicComponents(overridableIdPrefix, overridableComponentIds)

const components = {
...internalComponentDefaults,
...config.formConfig.defaultComponents,
...defaultComponentOverrides,
...dynamicComponents
};

loadComponents(overridableIdPrefix, components).then((res) => {
Expand Down

0 comments on commit 6142b57

Please sign in to comment.