trueadm / t7

Lightweight virtual DOM templating library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working with current version React.js

differui opened this issue · comments

  • React.js 15.4.2
  • t7.js 3.10.3
// 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.

I should read docs first next time. 😂