Skip to content

Instantly share code, notes, and snippets.

@kadmil
Created July 10, 2016 15:08
Show Gist options
  • Save kadmil/65fe9270ce3f75bd6c0d0257b975f3b2 to your computer and use it in GitHub Desktop.
Save kadmil/65fe9270ce3f75bd6c0d0257b975f3b2 to your computer and use it in GitHub Desktop.
React like a pro
import React from 'react'
export default (props) => (<div>{props.myText}</div>)
import React from 'react'
import First from './first.jsx'
export default (props) => ({[1,2,3].map((el) => (<First myText={el}>))})
@yoshuawuyts
Copy link

First

const html = require('choo/html')
const assert = require('assert')

module.exports = function first (myText) {
  assert.equal(typeof myText, 'number')
  return html`<div>${myText}</div>`
}

Second

const html = require('choo/html')
const assert = require('assert')
const First = require('./first')

// make sure when mounting in the view, there's a single root node - not multiple; else
// `hyperx` will complain
module.exports = function second (myText) {
  assert.equal(typeof myText, 'number')
  return [ 1, 2, 3 ].map((el) => {
    return First(el)
  })
}

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