This is correct, I missed that the JsonFormsStateProvider doesn’t just use the initState but handles its attributes manually. Therefore you also need to adapt the JsonFormsStateProvider to get the config into the state.
I would like to suggest to place the code below into a separate file and import that version of JsonForms into your application instead of the “original” one. Once we extend the JsonForms component all you have to do is to remove the file again and adjust your imports.
import { useReducer, useEffect } from 'react';
import {
coreReducer,
rendererReducer,
cellReducer,
Actions,
Generate,
} from '@jsonforms/core';
import { JsonFormsContext, JsonFormsDispatch } from '@jsonforms/react';
const JsonFormsStateProvider = ({ children, initState }) => {
const [core, dispatch] = useReducer(coreReducer, initState.core);
const [renderers] = useReducer(rendererReducer, initState.renderers);
const [cells] = useReducer(cellReducer, initState.cells);
const { data, schema, uischema, ajv, refParserOptions } = initState.core;
useEffect(() => {
dispatch(Actions.init(data, schema, uischema, { ajv, refParserOptions }));
}, [data, schema, uischema, ajv, refParserOptions]);
return (
<JsonFormsContext.Provider
value={{
core,
renderers,
cells,
config: initState.config,
dispatch,
}}
>
{children}
</JsonFormsContext.Provider>
);
};
export const JsonForms = (props) => {
const {
ajv,
data,
schema,
uischema,
renderers,
cells,
refParserOptions,
onChange,
config,
} = props;
const schemaToUse = schema !== undefined ? schema : Generate.jsonSchema(data);
const uischemaToUse =
typeof uischema === 'object' ? uischema : Generate.uiSchema(schemaToUse);
return (
<JsonFormsStateProvider
initState={{
core: {
ajv,
data,
refParserOptions,
schema: schemaToUse,
uischema: uischemaToUse,
config,
},
renderers,
cells,
}}
>
<JsonFormsDispatch onChange={onChange} />
</JsonFormsStateProvider>
);
};
I hope this helps 