我在水平 FlatList (react-native-snap-carousel) 中有部分列表。每个SectionList 项目代表时间线中的一个条目。有些项目只是文本,其他项目也有图像。
滚动时,每当屏幕上出现图像时,fps 就会下降到 10 以下。如果我简单地注释<Image>标签以便不渲染图像,则 fps 会上升到 50>fps。
左边的应用程序有图像,右边的应用程序有<Image />组件评论。
我只在 Android 上测试了该应用程序。有什么解释为什么显示图像时 fps 会下降吗?
渲染项目:
render() {
const {
containerStyle,
hourStyle,
hourTextStyle,
contentStyle,
iconDashesStyle,
titleText,
descriptionText,
notesText
} = styles;
const activity = this.props.item;
const { type, category, date, note } = activity;
return (
<View style={containerStyle}>
<View style={hourStyle} >
<Text style={hourTextStyle}>
{moment(date).format('HH:mm')}
</Text>
</View>
<View style={iconDashesStyle}>
{this.renderIcons()}
{this.renderDashes()}
</View>
<View style={contentStyle}>
<Text style={titleText}>{getActivityName(type, category).toUpperCase()}</Text>
<Text style={descriptionText}>{getActivityDescription(activity)}</Text>
<Text style={notesText}>{note}</Text> …Run Code Online (Sandbox Code Playgroud) 我有一个包装在react-redux“连接”中的组件。该组件的所有道具均由mapStateToProps和MapDispatchToProps提供,因此没有“ ownProps”传递给该组件。
但是,我收到以下流错误:
Cannot create Credits element because props [1] is incompatible with empty [2].
src/components/ChildrenView/index.js
323? />
324?
325? {/* Credits */}
[1] 326? <Credits />
327?
328? {/* fullscreen pictures rhat open with onClick on tge image */}
329? <PhotoViewer />
flow-typed/npm/react-redux_v5.x.x.js
[2] 110? CP: $Diff<ElementConfig<Com>, RSP>,
Run Code Online (Sandbox Code Playgroud)
我正在使用流类型,您可以在错误中指出。
这是类定义和connect调用:
type Props = {|
...mapStateToPropsType,
pricingModal: typeof pricingModal,
offlineModal: typeof offlineModal,
|}
class Credits extends React.Component<Props> { ... }
type mapStateToPropsType = {|
balance: number,
isVisiblePricing: boolean, …Run Code Online (Sandbox Code Playgroud) 这是Android的本机问题。
当 TextInput 被聚焦时,如何处理 Android 中的后退按钮?
BackHandler.addEventListener('hardwareBackPress'. () => {})如果 TextInput 为焦点,则不会捕获任何事件。它会自动关闭键盘。
(实际上我想要实现的是在按下后退按钮并关闭键盘时移除光标)
你可以玩这个世博小吃来了解我在说什么:
我是使用flow的新手,因此我可能会犯一些非常愚蠢的错误。
我想创建一个Props流类型,该类型与传递给组件的props,从mapStateToProps返回的redux存储中获得的props和mapDispatchToProps上定义的一些动作创建者相交。
下面显示的所有代码均可在该流try上使用。
让我们考虑一下以下状态和动作创建者:
// State type
type State = {
state_text: string,
state_num: number,
}
// Action type
type Action =
| { type: 'ACTION_CREATOR_1', text: string}
| { type: 'ACTION_CREATOR_2', value: number}
// action creators
const actionCreator_1 = (): Action => ({
type: 'ACTION_CREATOR_1',
text: 'some text',
})
const actionCreator_2 = (num: number): Action => ({
type: 'ACTION_CREATOR_2',
value: num + 1,
})
Run Code Online (Sandbox Code Playgroud)
我按照这篇文章中的示例进行操作,然后使用类似以下的内容来定义我的类型:
const mapStateToProps = (state: State) => {
const …Run Code Online (Sandbox Code Playgroud)