Closed pascallaprade closed 6 years ago
@pascallaprade Thank you, Solved in v2
I think it still requires a string while working with any node.
my case:
confirmAlert({
title: <div css={{ marginBottom: 20 }}>{t('catalogue.confirmationDialogue.confirmHeader')}</div>,
message: <div>
{t('catalogue.confirmationDialogue.from')}
<br /><br />
<b>{props.children || 'n/a'}</b>
<br /><br />
{t('catalogue.confirmationDialogue.to')}
<br /><br />
<b>{text}</b>
</div>,
onKeypressEscape: handleInputBlur,
buttons: [
{
label: t('catalogue.confirmationDialogue.yes'),
onClick: async () => {
await props.editItem({ itemId: props.item.id, field: props.fieldName, value: text })
setEditing(false)
}
},
{
label: t('catalogue.confirmationDialogue.no'),
onClick: handleInputBlur
}
]
})
throwing errors for both title and message
Failed prop type: Invalid prop `title` of type `object` supplied to `ReactConfirmAlert`, expected `string`.
and still rendering perfectly
@michalpokojski
This case you can use prop childrenElement
instead of title
and message
example:
confirmAlert({
childrenElement: () => (
<>
<h2>Title</h2>
<div>Some message</div>
</>
),
buttons: [...]
});
The prop types for your component only allow string to be passed for the title, message, confirm label and cancel label. However, the code clearly supports anything that can be rendered, and providing a span element, for instance, works perfectly.
The prop types should be less restrictive, and be
PropTypes.node
instead ofPropTypes.string
.