必须保证后面用到this.state之前,对state有初始化,否则是null 3. preact相关的router迁移回react生态 首先,import的preact-router得换成react-router preact-router: <Router history={history}> <Main path="/" history={history} /> path="/new_user" history={history} component={NewUser} />
必须保证后面用到this.state之前,对state有初始化,否则是null 3. preact相关的router迁移回react生态 首先,import的preact-router得换成react-router preact-router: <Router history={history}> <Main path="/" history={history} /> Route path="/new_user" history={history} component={NewUser} />
本文作者:IMWeb EnjoyChan 原文出处:IMWeb社区 未经同意,禁止转载 背景 考虑到移动端性能,腾讯企鹅辅导移动端项目使用了更为轻量的 preact(7KB) 及其对应配套 preact-router
而Preact也有提供preact-redux和preact-router,甚至还有帮助Preact做同构直出的preact-render-to-string。