简体   繁体   English

响应本机FlatList样式更改

[英]React Native FlatList style change

I am using Flatlist to present my data and when I click button 1 I want to change my view! 我正在使用Flatlist展示我的数据,当我单击按钮1时,我想更改视图! From A to B! 从A到B! What's the best way to do it? 最好的方法是什么? I've tried render two different styles at the same time but I set one of them height 0! 我尝试同时渲染两种不同的样式,但我将其中一种设置为高度0! Also I've tried to use state to decide which style I want to show! 另外,我尝试使用状态来决定要显示的样式! These two solutions work fine but I think it's kinda slow to change from A to B or B to A. So are there any other ways to do it? 这两种解决方案都可以正常工作,但我认为从A更改为B或从B更改为A有点慢。那么还有其他方法可以做到吗? Thank you in advance!! 先感谢您!!

在此处输入图片说明

You have to use the concept of conditional Rendering. 您必须使用条件渲染的概念。 You can use this resource Conditional Rendering . 您可以使用此资源“ 条件渲染”

Just change the Flatlist View based on state Value using Conditional Rendering. 只需使用条件渲染基于状态值更改Flatlist视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM