wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

Write single file component like vue. #197

Open windyGex opened 7 years ago

windyGex commented 7 years ago

I write a webpack loader named seek-component-loader. It support write single file component like vue, but using react-templates compile content.

https://github.com/windyGex/react-template-loader

<SeekComponent>
<template>
  <input className="new-todo" type="text" placeholder="What needs to be done?"
    onKeyDown="{this.handleKeyDown.bind(this)}" />
</template>

<style lange="sass">
  .new-todo {
  }
</style>

<script>
  import React from 'react'

  export default class AddTodo extends React.Component{
    handleKeyDown (e){
      let {handleAddTodo} = this.props;
      if (e.keyCode === 13) {
          const text = e.target.value.trim()
          if (text) {
            handleAddTodo(text)
            e.target.value = ''
          }
      }
    }
  }
</script>
</SeekComponent>

Anyone interested?

nippur72 commented 7 years ago

Cool, it's also similar to RiotJs (no surprise since Riot inspired Vue).

hongbuzz commented 7 years ago

Cool! What I looking for

mikeaustin commented 7 years ago

I was poking around for jsx template solution. I like this. I also found https://www.npmjs.com/package/react-html-template-loader. The benefits are being able to preview the HTML.