MCPcopy Index your code
hub / github.com/formkit/formkit / FormKitProvider

Function FormKitProvider

packages/react/src/FormKitProvider.ts:106–131  ·  view source on GitHub ↗
(props: FormKitProviderProps)

Source from the content-addressed store, hash-verified

104 * The FormKitProvider component provides FormKit config to descendants.
105 */
106export function FormKitProvider(props: FormKitProviderProps) {
107 const { config, children, ...attrs } = props
108 const providedConfig = useConfig(config)
109 const renderedChildren = passThroughChildren(children, attrs)
110
111 useEffect(() => {
112 if (!providedConfig) return
113 if (typeof window !== 'undefined') {
114 globalThis.__FORMKIT_CONFIGS__ = (
115 globalThis.__FORMKIT_CONFIGS__ || []
116 ).concat([providedConfig.rootConfig])
117 return () => removeConfig(providedConfig.rootConfig)
118 }
119 return
120 }, [providedConfig])
121
122 if (!providedConfig) {
123 return createElement(Fragment, null, renderedChildren)
124 }
125
126 return createElement(
127 optionsSymbol.Provider,
128 { value: providedConfig.options },
129 createElement(configSymbol.Provider, { value: providedConfig.rootConfig }, renderedChildren)
130 )
131}
132
133function FormKitConfigLoader(props: ConfigLoaderProps) {
134 const {

Callers

nothing calls this directly

Calls 4

createElementFunction · 0.90
passThroughChildrenFunction · 0.85
useConfigFunction · 0.70
removeConfigFunction · 0.70

Tested by

no test coverage detected