preact

GMTC全球大前端技术大会-未来已来

一世执手 提交于 2020-12-19 05:58:36
GMTC-2019北京 GMTC这次的大会的热词肯定是监控、性能,当然跨平台依然是热点, write once,run anywhere! ,以下是自己参加的总结心得。 6.20上午 前端的演化 核心理念:结构+样式+表现分离 -2003 前端岗位的出现 核心理念90%优化在前端 工程化的开始 核心理念:前后端分离 全栈的演进 核心理念:mobile first 无线时代来临 核心理念:LOw/No Code 中后台的重塑 未来? 最大的感触是阿里的圆心讲的,国内前端的标准与世界的差距,前端世界权威组织机构是TC39、W3C和node基金会,国内对行业标准的贡献度有很大差距 6.21下午 极致前端性能优化探索 贝壳 项目自研做监控系统,时光机、日志分析平台 对了还分享了下gizip的原理:LZ77算法、Huffman 文本68% 图片6.3% 对图片做压缩 消除替换图像 矢量图、光栅图优化 有损压缩与无损压缩 图片转行样式表 抽离像素通道 手动刷新运营商缓存,强制缓存图片 投放广告,携带图片缓存到本地 6.22 B站的视频体验进化之路 bilibili 关键资源优先加载 bundle缩小 SSR+SPA 弹幕:mask-image 0.3秒完成渲染!信息流内容页“闪开”优化总结和思考 阿里巴巴 直出无白屏,动画流畅不卡顿 CSR SSR NSR data

Jest tests on React components: Unexpected token “<”

这一生的挚爱 提交于 2020-05-15 05:27:40
问题 Trying to set up Jest to test my React components (Technically I'm using Preact) but same idea... Anytime I try to get a coverage report, I get errors when it hits any jsx syntax. Error Running coverage on untested files...Failed to collect coverage from /index.js ERROR: /index.js: Unexpected token (52:2) 50 | 51 | render( > 52 | <Gallery images={images} />, | ^ I've tried following the docs and similar issues but no luck! It seems as though my babel settings aren't getting used by Jest. Any

Jest tests on React components: Unexpected token “<”

放肆的年华 提交于 2020-05-15 05:27:27
问题 Trying to set up Jest to test my React components (Technically I'm using Preact) but same idea... Anytime I try to get a coverage report, I get errors when it hits any jsx syntax. Error Running coverage on untested files...Failed to collect coverage from /index.js ERROR: /index.js: Unexpected token (52:2) 50 | 51 | render( > 52 | <Gallery images={images} />, | ^ I've tried following the docs and similar issues but no luck! It seems as though my babel settings aren't getting used by Jest. Any

80行代码实现Preact-Transition组件

六月ゝ 毕业季﹏ 提交于 2020-05-09 20:20:55
Preact是3kb轻量化方案, 但是一些基础组件找起来比较困难, 用起来也比较别扭,其中一个就是Transition组件, 尝试过** preact-transition-group **, 但是直接npm安装使用就报错了...因为有个preact版本兼容问题 transition.js // 这一行代码没兼容, 新版preact children不一定是都是数组 359 - const child = children[ 0 ] + const child = children[ 0 ] || children 360 return cloneElement(child, childProps) 复制代码 但是看了transition.js (391行) + CSSTransition(181行), 感觉不需要这么多行代码即可实现所需的Transition组件 并且在使用过程中timeout的配置竟是比较迷惑... 所以就有了造论子的机会了 const PopupBaseLayout = ({ children, canClass = '' , position = 'bottom' , }) => { const { enter, onContentExited } = useContext(PopupContext) const transProps = { appear

小程序跨页面交互的作用与方法

筅森魡賤 提交于 2020-01-07 02:03:28
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 去年年末,微信小程序的分包大小已经到达了 12M 大小,一方面说明小程序的确逐步为开发者放开更大的权限,另一方面也说明了对于某些小程序 8M 的大小已经不够用了。我个人今年也是在开发一个 to B 小程序应用。这里列举一些跨页面交互的场景。 对于 B 端应用的业务需求来说,小程序开发的复杂度相对比网页开发要复杂一些。一个是双线程的处理机制问题,另一个是页面栈之间交互问题。 注: 笔者目前只需要开发微信小程序,为了在小程序页面中可以使用 properties behaviors observers 等新功能,已经使用 Component 构造器来构造页面。具体可以参考 微信小程序 Component 构造器 。如果你也没有多端开发的需求,建议尝试使用,可以得到不错的体验。 性能优化类 对于小程序在页面中点击触发 wx.navigateTo 跳转其他页面,中间会有一段时间的空白加载期(对于分包出去的页面,空白期则会更长),但是这是小程序内部机制,没有办法进行优化。我们只能眼睁睁的等待这段没有意思的空白期过去。 当考虑到跳转页面后的第一件事情便是取数逻辑,那么我们是否能够进行优化呢?答案是肯定的。我们没有办法直接在当前页面取得数据之后再进行跳转操作(这样操作更不好),但是我们却可以利用缓存当前的请求

Pass array of strings to React component with string coming from json file and allow inline span tags

社会主义新天地 提交于 2019-12-11 16:55:53
问题 I'm trying to get an array of strings to display as paragraphs and allow an inline span tag inside of these strings. My issue comes is when the value is added inside the paragraph the decodes the "<" and ">" tag start and ends to their decoded values "<" and ">" Is there an easy way to get this working without making a specific component for this case? My React component is as follows const Paragraphs = ({ data, languageText }) => { if (data) { const texts = languageText[data.languageKey];

What makes a React library require preact-compat?

烈酒焚心 提交于 2019-12-11 13:46:48
问题 I have noticed that certain libraries such as classnames are readily available in Preact but others like styled-components require preact-compat . What makes a React library unsupported natively in preact that it requires the use of preact-compat? 回答1: Disclaimer: I work on preact. There are several APIs in react that are not needed for preact . But because existing third-party libraries have been developed for those APIs we published preact-compat which re-implements them on top of preact .