ScrollView Custom Scroll Indicator
Custom Scroll Indicator for ScrollView
1 | import React, { useMemo, useState } from "react" |
1 | import React, { useMemo, useState } from "react" |
Set 类似于数组,但是成员的值都是唯一的,没有重复。Set 本身是一个构造函数。
1 | const set = new Set() |
在 Set 内部,NaN 是相等的,两个对象总是不相等的。
1 | let set = new Set() |
如果 wrapp 的 flex-direction 为 row 的时候,Text 内部不自动 wrap。还是测试拿给我看,才发现某些机型会存在这种问题。
开始以为是 Text 内部会根据flexbox
而有不同的展现,但是翻阅官方文档:
The
element is unique relative to layout: everything inside is no longer using the Flexbox layout but using text layout. This means that elements inside of a are no longer rectangles, but wrap when they see the end of the line.
Text 组件内部默认是 wrap
的,除非这一整个是一个超长的单词,否则就会在 white space 的时候自动 break 了。
如果给 wrapp 设置 wrap,那么整个 text 直接就 wrap 到下一行,icon 单独一行了。(这部分官方是有案例的,根据 Text 外部的 Container,wrap 也是不一样的)
好嘛,到底是什么东西导致的?为什么 flex-direction: row 就给我炸了?
原因: element 的宽度计算方式导致的
官方的解释:每个 element 的 size 大致可以分为两种方式:
解决方法也很简单,Text 上挂一个 flexShrink: 1,让它自己玩去吧。
1 | var promise = new Promise(function (resolve, reject) { |