Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return React.Children.map(children, child => {
if (child === null) {
return child;
} else if (child.type === Form.Field) {
const name = child.props.name;
let error = this.state.formErrors ? this.state.formErrors[name] : null;
let clonedElement = child;
if (error) {
error = error[0]
? error[0].message.replace(name, child.props.label)
: null;
clonedElement = React.cloneElement(child, {
errorText: error
});
}
return React.cloneElement(clonedElement, {
events: ["onBlur"]
});
} else if (child.type === Form.Button) {
return React.cloneElement(child, {