Recursion and React
Hey friends! 👋
Whenever I teach someone React for the first time, I take the time to demonstrate React without JSX by first using React.createElement()
.
"Why would you do that Kyle? No one uses React that way in a real app," you say.
Because I want to make it clear that JSX isn't magic. ✨ It simply a friendlier syntax for nesting functions because React components are just functions.
Because they are just functions, we can use any pattern we use with other functions with React components. Patterns like recursion.
If you're not familiar with recursion, or just want to see what it looks like in React, you might be interested in my latest blog post: Recursive React Components
Check it out, share it with your friends, and let me know what you think on Twitter. Hope you find it useful!
-Kyle