trueadm / t7

Lightweight virtual DOM templating library
900 stars 31 forks source link

Not working with current version React.js #31

Closed differui closed 7 years ago

differui commented 7 years ago
// index.js
const virtual_dom = t7`
  <h1>test</h1>
`;

ReactDOM.render(virtual_dom, document.querySelector('#app');

ReactDOM deny to render no-react-element and rise exception:

Uncaught Error: ReactDOM.render(): Invalid component element.

According to implementation in React.isvalidelement.Do little trick:

// index.js
const virtual_dom = t7`
  <h1>test</h1>
`;

virtual_dom.$$typeof = Symbol.for('react.element');
ReactDOM.render(virtual_dom, document.querySelector('#app');

Rise another exception:

Uncaught Error: Element type is invalid: expected a string (for built-in components) 
or a class/function (for composite components) but got: undefined. 
You likely forgot to export your component from the file it's defined in.
differui commented 7 years ago

I should read docs first next time. 😂