1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

react nativeのTips(メモ)

Last updated at Posted at 2018-07-20

react nativeのTips(メモ)

FlatListでマルチカラムを実現したい。


属性にnumColumnsを持たせたあげる。
example.js
<FlatList ref={(ref)=>{this.fList = ref;}} style={styles.listView} numColumns={3} execData={ex} data={ex} keyExtractor={(item, index) => item.ex} renderItem={this._renderItem} />

個人的には子要素styleにflex:1を持たせたあげるときれいになると思う。

こんな感じ

S__111812663.jpg

react navigationでheaderのボタンで画面遷移したい。

navigation optionにnavigation引数を持たせる。

example.js
navigationOptions: ({ navigation })=>({
  header: <View style={{backgroundColor:'#222'}}>
    	    <TouchableOpacity style={{alignSelf: 'flex-start',marginLeft:10,}} onPress={()=>{navigation.goBack()}}>
    	      <Icon color='#FFF' name={'chevron-left'} size={35} />
    	    </TouchableOpacity>
    	  </View>,
		 })

以下、随時追加していきます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?