Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>Why don't you actually recreate the snippet of code up there.

I've never coded in React or Vue but after spending 15 mins reading https://vuejs.org/v2/guide/render-function.html here's a pure JS re-creation in Vue for you (fiddle here: https://jsfiddle.net/0wr6xskh/):

  <div id="app"></div>

  const MyHeader = Vue.component('MyHeader', {
    render: function (createElement) {
      return createElement('h1', this.text)
    },
    props: {
      text: {
        type: String,
        required: true
      }
    }
  });

  new Vue({
    el: '#app',
    render: function (createElement) {
      return createElement('div',[
        createElement(MyHeader, {
          props: {
            text: ''+new Date()
          }
        })
      ])}
  });
The above could be expressed more succinctly in JSX (I just can't be bothered reading up on the syntax since, as mentioned, I've never written anything in it and consequently don't know it). More info on Vue's JSX support here: https://vuejs.org/v2/guide/render-function.html#JSX


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: