折腾:
期间,需要把库:
CassetteRocks/react-infinite-scroller: ⏬ Infinite scroll component for React in ES6
的代码转换为Preact的代码
已经把:
import React, { Component, } from ‘react’; |
换成:
import { Component } from ‘preact’; |
了。
现在要去把:
render() { 。。。 return React.createElement( element, props, …childrenArray, ); } |
中的React.createElement也换成Preact代码。
搜:
preact React.createElement
Differences to React · developit/preact Wiki
Possible to alias React.createElement to h? (no preact-compat) · Issue #692 · developit/preact
React.createElement · Issue #168 · developit/preact
【总结】
然后React.createElement把换成Preact中的h即可:
import { h, Component } from ‘preact’; render() { 。。。 //return React.createElement( return h( element, props, …childrenArray, ); } |