TroyAlford / react-jsx-parser

A React component which can parse JSX and output rendered React Components.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't parse component composition - only functions props

YossiSaadi opened this issue · comments

Reproduce:
https://codesandbox.io/p/sandbox/react-jsx-parser-1-29-0-component-composition-b-53qnmd

const jsx = `<Button someComponent={Component}>I'm children</Button>`
...
<JsxParser components={{ Button, Component }} jsx={jsx} />
const Button = ({ someComponent, children }) => {
  return <button>{someComponent || children}</button>;
};
...
const Component = () => {
  return <div>I'm some component</div>;
};

Result:
image

Yes, that is somewhat strange behavior - but I'm not sure why you would expect the Component to render. You neither rendered it nor invoked it.