react-view icon indicating copy to clipboard operation
react-view copied to clipboard

Make `props.value` accept JSX

Open raunofreiberg opened this issue 6 years ago • 1 comments

I've recently been writing a lot of "stringified JSX", which can become quite hard to maintain.

Would it be possible to provide props.value or initialCode as JSX?

For example:

const config = {
	initialCode: () => {
		const [flag, setFlag] = useState(false);
		const handleClick = () => setFlag(true);

		return (
			<div>
				<Button onClick={handleClick}>Set flag</Button>
			</div>
		);
	},
	scope: { Button },
};

<hr />

Possibly related or duplicate of #10?

raunofreiberg avatar Feb 03 '20 17:02 raunofreiberg

The approach in #10 could work (might be more complicated due to JSX).

tajo avatar Feb 03 '20 18:02 tajo