But guess what? React hasn't been for a long time. And because it's a template and not a function, there's no need for a return statement because templates are statements and so they're not returned as expressions. The other thing that will have potentially jumped out at you is that in Ripple, you cannot just throw strings into your JSX. They must be wrapped in curly braces. But experienced React devs that reformat their JSX with Prettier will know that if you need a space at the end of a line, you've already seen this with the curly and the space in a string. So here the same thing applies.
How about flow control? So some of you old-timers might remember that when React came out, everyone was all like, why is there HTML in my JavaScript? So with Ripple, because the components are just templates, you can just put JavaScript right in the JSX. So at first, the first time you see this, it might blow your mind. But to be honest, the ternary Boolean logic over here in React land, while I can stand it, like, it's not very nice to work with. Like many bugs have been introduced because of that syntax. And you may have spotted the ampersand here that is doing the lazy destructuring of this prop. And when I include the ampersand, it's not just reading the value, it's telling the system, this piece of UI depends on this value. That's how Ripple knows to update when the online variable changes. So if a value should cause UI to update when it changes, you need to destructure it with ampersand.
How about looping over data? Well, while I never really hated the functional mapping over stuff, in Ripple, you can just use a for loop, feels a lot more just JavaScript, if you ask me. And of course the same goes for switch statements and try and catch. You want an error boundary, wrap it in a try catch. And try catch also has a suspense version, so rather than catch, you can use pending, you can put your output there. And by the way, if you like this syntax for writing JSX, but aren't quite ready for lazy destructuring or don't want to move your whole app over to Ripple, I have some good news for you. The author of Ripple, in an attempt to make onboarding much more easy, has abstracted this out into its own TypeScript plugin called TSRX. And guess what? You can use this in your favorite front-end language. You can add this to TypeScript as a plugin and then you can write TSRX with this form of building components, and it will output to React or whatever. There's a great playground on that website for you to look and see, get a feel. It's really well done.
Comments