'Can I use a React element in the message property of yup's createError(...)?

The yup documentation specifically states that I should return a string in context.createError({ message: "string here" }). However, I would like to do something like this:

return context.createError({
    message: (
        <ul>
            {suggestions.map((s, i) => <li key={i}>{s}</li>)}
        </ul>
    )
});

It does seem to work fine, but I'm unsure if there is some small possibility of this breaking?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source