jsifyPropTypes method
JsMap
jsifyPropTypes(
- covariant Component2 component,
- covariant Map<
String, Function> propTypes
override
Implementation
@override
JsMap jsifyPropTypes(
covariant Component2 component, covariant Map<String, /*PropValidator<Map>*/ Function> propTypes) {
return JsBackedMap.from(propTypes.map((propKey, validator) {
// Wraps the propValidator methods that users provide in order to allow them to be consumable from javascript.
dynamic handlePropValidator(
JsMap props,
String propName,
String? componentName,
String location,
String? propFullName,
// This is a required argument of PropTypes but is usually hidden from the JS consumer.
String? secret,
) {
// Create a Dart consumable version of the JsMap.
final convertedProps = JsBackedMap.fromJs(props);
// Call the users validator with the newly wrapped props.
final error = validator(
convertedProps,
PropValidatorInfo(
propName: propName,
componentName: componentName,
location: location,
propFullName: propFullName,
));
return error == null ? null : _JsError(error.toString());
}
return MapEntry(propKey, allowInterop(handlePropValidator));
})).jsObject;
}