Why is props.children kept always as an array when using overrides?
React usually keeps props.cihldren as a single string and not as an array if it contains just one element. Is there a reason? Problem is code consistency: You need to have a condition for components to render within and outside of <Markdown>'s overrides if you do sophisticated stuff with props.children.
Check the sandbox' console: https://codesandbox.io/s/reverent-bas-fp4m6
I solved it with the option below. Now, also props that previously came as arrays are also fixed to strings. Also rendering of MD within JSX keeps working.
Still wondering why an array is returned with the default implementation or is it a bug?
...
option={{
createElement: (type, props, children) =>
React.createElement(
type,
props,
children && children.length === 1 ? children[0] : children
),
...
I have the same issue. Trying to override native <a> link with next/link component but got the following error:
Warning: Failed prop type: Invalid prop
childrenof typearraysupplied toNextLink, expectedobject.