Skip to content

Commit 7c7a975

Browse files
committed
doc: add jsdoc comment for dynamicParametrize
1 parent 214e88d commit 7c7a975

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib/utils/fieldComponents.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import { useFormikContext } from "formik";
22
import * as React from "react";
33

4+
/**
5+
* Override the parameters of a component (similarly to `parametrize`) using certain available
6+
* context variables.
7+
*
8+
* Currently, the following arguments are passed into the `propsFactory` function:
9+
* - `formValues`: an object of the values in the Formik form state
10+
*
11+
* The `propsFactory` function should return an object of the props to be used for overriding the
12+
* specified `Component`
13+
*
14+
* This function is adapted from `react-overridable`: https://github.com/indico/react-overridable/blob/d1ecfbec9993a461717824259900eec82d59f1e0/src/overridable.js#L7-L33
15+
*
16+
* @param Component - the React component to override the parameters, as in `parametrize` from react-overridable.
17+
* @param {function} propsFactory - function returning the props to override the component with
18+
*/
419
export function dynamicParametrize(Component, propsFactory) {
520
const ParametrizedComponent = (props) => {
621
const { values } = useFormikContext();

0 commit comments

Comments
 (0)