algolia/react-element-to-jsx-string

Option to not render values

areknow opened this issue · 1 comments

Not sure how to word it exactly, sorry about that..

I would like to show the code:

<Button
  onChange={() => {
    setCount(count + 1);
  }}
>
  clicked: {count}
</Button>

But instead I am getting the rendered value of {count}:
Screen Shot 2021-03-15 at 5 11 41 PM

Is this possible?
Thanks!

Hi @areknow,

Your exemple will transpiled to something like this:

React.createElement(Button, { onChange: () => setCount(count + 1) }, `clicked: ${count}`);

The third argument will be resolved a runtime to became the string clicked: 2. So it's not possible for the library to retrieve it.