Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native篇 #52

Open
seaify opened this issue Oct 29, 2016 · 0 comments
Open

react-native篇 #52

seaify opened this issue Oct 29, 2016 · 0 comments

Comments

@seaify
Copy link
Owner

seaify commented Oct 29, 2016

  1. view未指定大小信息时,要么设定宽度和高度,要么设定flex, 否则是不会显示的,因为默认size设置为0了
  2. 为什么有时候指定flex: 1, 有时候不指定flex
  3. 如何开启本地模式,输出更详细的错误信息
  4. react-native-button,被view wrap一层之后,位置向下偏移了,
  5. react-native的版本变更后,会出现react-native module not found,是需要重新运行react-native start --port 9090这种
  6. _.extend(this.props.fetch_url_param, query_params ), 这种写法是有问题的,extend, 会去修改第一个object, 但是props不应该被修改,而且没效果
    
  7. listview, onEndReached反复被调用
  8. scrollview, listview有时候会显示不全,解决办法是它的parent都必须有flex: 1, 如果是设定固定高度,也会有这个问题
  9. flex: 1, width: 20, 并存的情况下,width是无效的
  10. flex: 1, 针对的是其wrap的元素
  11. textinput, 不指定高度,或者flex: 1的话,是不会显示的,但是text默认会显示, 估计是因为text的高度默认等于内容的高度
  12. react-native在xcode编译生成到手机上连机运行时,如果退出app, 重新运行,日志将不会再输出到xcode里, 只有第一次开启app时正常
  13. voiceover, text自身之读取了本身的内容,而上一层的容器,才返回了内容+按钮信息
  14. react-native在开发阶段,一定要dev=true, 使得各种waring信息更详细, 比如display: flex, border,都是不合法的,但是dev=false,就不会提示
  15. 函数里,如果出现了forEach这种, this变量变成了函数自身,而不是本来的this了
    

var that = this

this.state.history_querys.forEach(function(query){
  querys.push(
    <TouchableOpacity onPress={() => that.set_query(query)} >
      <View>
        <Text style={styles.history_text}>{query}</Text>
        </View>
    </TouchableOpacity>
  );
});

16, 在simluator已经运行起来的情况下,替换图片,并没有生效
17, react-native组件的props输入变更后,只会调用willupdate, 但是render中使用的如果并不直接是props, 那页面是不会刷新的.

正确的流程是,通过didupdate, 去更新state, 而view里使用state

  1. 不要乱用scrollview的contentContainerStyle
  2. 同一个层级的child, 一个用flex:1, 一个不用,应该是会有问题的。
  3. 尽量的少wrap view层
    21, 具体到某个元素的上下对齐时,抽离出一个view, 指定大小,背景,如
    How to vertical center and horizontal center <Text>xxx/<Text> ? facebook/react-native#325
  4. 将图片对齐时,水平,竖直的话,parent容器,需要指定宽度和高度
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant