Skip to content

Instantly share code, notes, and snippets.

@onurkerimov
Last active October 15, 2020 12:43
Show Gist options
  • Save onurkerimov/4e8c89a27eada02419c430f300a4106a to your computer and use it in GitHub Desktop.
Save onurkerimov/4e8c89a27eada02419c430f300a4106a to your computer and use it in GitHub Desktop.
const Tree = (props) => (
<ul>
{props.nodes.map((node, key) => (
<li key={key}>
<div className={'name'}>{node.name}</div>
{node.children && <Tree nodes={node.children} />}
</li>
))}
</ul>
);
render(<Tree nodes={tree} />, document.getElementById('root'));
@onurkerimov
Copy link
Author

onurkerimov commented Aug 2, 2020

Alternative syntax that compiles to JS (Inspired by Imba)

const Tree = (props) => <ul>
  props.nodes.map @ (node, key) => <li key>
    <div className='name'>node.name
    node.children && <Tree nodes=node.children />

render @ <Tree nodes=tree />, document.getElementById('root')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment