轉自 www.ucamc.com/e-learning/javascript/276-react-js-search搜尋功能使用過濾迴圈filter.html
--
filter函數特性:
dizzy03 發表在 痞客邦 留言(0) 人氣(3)
onChangeText is basically a simplified version of onChange, so you can easily use it, without the hassle of going through event.target.value to get changed value.
So, when should you use onChange and when onChangeText?
If you have simple form with few textinputs, or simple logic, you can go straight away and use onChangeText
<TextInput value={this.state.name} onChangeText={(text) => this.setState({name: text})}>
If you have more complicated forms and/or you have more logic in handling data (like handling text differently from number) when user changes input, then you are better of with onChange, because it gives you more flexibility. For example:
handleChange(event) {
const {name, type, value} = event.nativeEvent;
let processedData = value;
if(type==='text') {
processedData = value.toUpperCase();
} else if (type==='number') {
processedData = value * 2;
}
this.setState({[name]: processedData})
}
<TextInput name="username" type="text" value={this.state.username} onChange={this.handleChange}}>
<TextInput name="password" type="number" value={this.state.password} onChange={this.handleChange}}>
dizzy03 發表在 痞客邦 留言(0) 人氣(1)

轉自 bbs.reactnative.cn/topic/444/同时兼容ios与android的toast组件
--
給大家安利一款可以在iOS和Android上通用的Toast組件: react-native-root-toast
現在開源的Toast組件一大堆,為什麼要選用這個呢?原因如下:dizzy03 發表在 痞客邦 留言(0) 人氣(0)

轉自 https://www.jianshu.com/p/e9144208f18f
--
dizzy03 發表在 痞客邦 留言(0) 人氣(0)
遊戲本體
https://store.steampowered.com/app/1097880/Super_Naughty_Maid_2/
dizzy03 發表在 痞客邦 留言(0) 人氣(55)
問題:
使用react-navigation接收navigation帶回來的參數,並且在navigationOptions中定義header區塊按鈕onPress時呼叫自訂function時,會直接出現"function is undefined"的錯誤訊息。
EX:
static navigationOptions = ({ navigation }) => ({
headerRight: <RightButton onPress={() => this.removeVehicle()} />
})
dizzy03 發表在 痞客邦 留言(0) 人氣(0)
答:
1. 使用react-native-vector-icons
<Icon name="facebook" style={styles.icon}>
<Text style={styles.text}>Login with Facebook</Text>
</Icon>
dizzy03 發表在 痞客邦 留言(0) 人氣(0)
答:
1. state設一個變數存true / false
2. 把if else判斷獨立成一個function,裏頭判斷變數是true就return內容,false就return null。
3. 在render的return中呼叫這個function,要不要顯示元件,控制state這個變數就好。
dizzy03 發表在 痞客邦 留言(0) 人氣(2)
問:
The story is, I should be able to put Bob, Sally and Jack into a box. I can also remove either from the box. When removed, no slot is left.
people = ["Bob", "Sally", "Jack"]
dizzy03 發表在 痞客邦 留言(0) 人氣(0)
RN下的取得input value方法跟平常JS不一樣,以往都是全部輸入完成後才去把值抓出來。
而在RN下資料和顯示基本上是連動的,input的value就對應到某個state變數,當value改變時其變數也一起改變,反之亦然。
TextInput要取值必須在onChangeText屬性中去取,取出來寫入某個state中某個變數,也就是在文字輸入時就一併變動,沒有事後再取值這回事。
dizzy03 發表在 痞客邦 留言(0) 人氣(0)