r/reactjs • • Jul 28 '19

Show /r/reactjs ScriptUI: Write React without JSX

https://github.com/anater/ScriptUI
3 Upvotes

26 comments sorted by

View all comments

1

u/[deleted] Jul 28 '19

Hi /r/reactjs!

I'm the author of ScriptUI. I whipped it up over the last few weekends as a proof of concept. I'm looking for feedback on whether you'd use something like this. I hope it helps make starting projects easier.

Thanks for reading!

4

u/friendshrimp Jul 28 '19

One thing that JSX gives us is named properties. I see this being useful if you are only passing a few props but as soon as you pass more than a few you’d have a confusing looking list of Paramus passed to a function.

1

u/[deleted] Jul 28 '19

That's a great point! Thanks for checking it out. I like to think there's still room for this through the use of an object literal or by leveraging modifiers.

For example:

// Object
const Button => ({ label, onClick }) => View("button", { onClick })(label);

// Modifier
const Button => ({ label, onClick }) => View("button")(label).set({ onClick });

// Custom Modifier for onClick is possible too
const Button => ({ label, onClick }) => View("button")(label).onClick(onClick);

// JSX
const Button => ({ label, onClick }) => <button onClick={onClick}>{label}</button>;