You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a tool that is dependent on an older version react-formal that includes the function addInputTypes to add the ability to add custom form types.
For the later versions that don't include addInputTypes, is there something similar? How do I transition my code from using addInputTypes? How do I get around this?
The text was updated successfully, but these errors were encountered:
There isn't any equivalent API now, but you can achieve effectively the same thing by wrapping the Field Component and using it's renderProp. We've found thhat this is ultimately more flexible and involves a good bit less code in the library (and for consumers).
Here is an example of how we do it. You can fairly easily imaging keeping a type map like the old API if you prefer that approach as well.
importBaseFormfrom'react-formal';importFormCheckfrom'./FormCheck';importFormControlfrom'./FormControl';importFormControlFilefrom'./FormControlFile';constAppFormField=React.forwardRef(({ children, as, ...props},ref)=>(<BaseForm.Fieldref={ref}{...props}>{innerProps=>{if(typeofchildren==='function')returnchildren(innerProps);const{ ...fieldProps}=innerProps;const{ type }=fieldProps;letInput=as;if(!Input){if(/checkbox|radio/.test(type)){Input=FormCheck;fieldProps.checked=fieldProps.value;fieldProps.value=props.value;}elseif(type==='file'){Input=FormControlFile;}else{Input=FormControl;}}return<Input{...fieldProps}>{children}</Input>;}}</BaseForm.Field>));
We have a tool that is dependent on an older version react-formal that includes the function addInputTypes to add the ability to add custom form types.
For the later versions that don't include addInputTypes, is there something similar? How do I transition my code from using addInputTypes? How do I get around this?
The text was updated successfully, but these errors were encountered: