Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- ์๊ณ ๋ฆฌ์ฆ
- react
- nlp
- ๋ฐ์ดํฐ๋ถ์
- ๊ฒฐ์ ํธ๋ฆฌ
- ๋ฐฑ์ค
- ๋ฐ์ดํฐ์๊ฐํ
- ๋ฐ์ดํฐ
- ํ๊ตญ์ด์๋ฒ ๋ฉ
- ๋์
- ๊นํ
- ์ํ์ฝ๋ฉ
- ์ธํ๋ฐ
- ์๋ฒ ๋ฉ
- ์ ํ๋์ํ
- Kaggle
- ๋ค์ดํฐ๋ธ
- Git
- ๋ฆฌ์กํธ
- ๋ถ์
- ์๋๋ก์ด๋์คํ๋์ค
- cs231n
- ๋ฅ๋ฌ๋
- Titanic
- native
- ๋จธ์ ๋ฌ๋
- linearalgebra
- AI
- c++
- ํ์ดํ๋
Archives
- Today
- Total
yeon's ๐ฉ๐ป๐ป
[React-Native ๊ธฐ์ด ๊ฐ์] TouchEvent ๋ณธ๋ฌธ
728x90
React-Native TouchEvent ์์ฑํ๊ธฐ
- ์๋ก์ด ํด๋(src) ์๋ ์๋ก์ด ํ์ผ(header.js) ์์ฑ
import Header from './src/header'
...
<View style={styles.mainView}>
<Header/>
</View>
- import๋ ํ์ !
- View ์์ importํ Header๋ฅผ ์ถ๊ฐํ๋ค.
const ํจ์ = () =>
const Header = () => (
<View style={styles.header}>
<Text>This is header</Text>
</View>
)
1. ์์ ๊ฐ์ด const ๋ค์ ( )์ฌ์ผ์ง jsx๋ฅผ ๋ฆฌํดํ ์ ์๋ค.
2. ๋ง์ฝ const ๋ค์ { }๋ผ๋ฉด ๋ฆฌํด๋๋ js component๊ฐ ์๋ค๋ ๊ฒ!
- jsx : javascript xml์ ์ฝ์ (javascript ํ์ฅ ๋ฌธ๋ฒ)
class App extends Component {
state = {
appName: 'My First App'
}
...
render() {
return (
<View style={styles.mainView}>
<Header name={this.state.appName}/>
</View>
- App.js์์ state ์์ ์๋ appName์ด๋ผ๋ ๋ณ์๋ฅผ header.js๋ก name์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ์ ๋ฌํ๋ค.
const Header = (props) => (
<View style={styles.header}>
<Text>{props.name}</Text>
</View>
)
- header.js์์๋ props๋ก ์ธ์๋ฅผ ๋ฐ์์ด!
View์์์ Touch ์ด๋ฒคํธ
• TouchOpacity
• TouchableWithoutFeedback : ํฌ๋ช ํด์ง์ง ์๊ณ alert์ฐฝ์ด ๋ธ
const Header = (props) => (
<TouchableOpacity
style={styles.header}
onPress={()=>alert('hello world')}
>
<View>
<Text>{props.name}</Text>
</View>
</TouchableOpacity>
- onLongPress : ์ค๋ ๋๋ฌ์ผ ์ด๋ฒคํธ ๋ฐ์
onLongPress={()=>alert('hello world')}
- onPressIn : ๋๋ฅด์๋ง์ ๋ฐ์์ด ์ค๋๋ก
onPressIn={()=>alert('hello world')}
- onPressOut : ํฐ์นํ๊ณ ์์ ๋์์ ๋ ๋ฐ์์ด ์ค๋๋ก
onPressOut={()=>alert('hello world')}
'Computer ๐ป > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[React-Native ๊ธฐ์ด ๊ฐ์] TextInput (0) | 2021.07.21 |
---|---|
[React-Native ๊ธฐ์ด ๊ฐ์] ScrollView (0) | 2021.07.21 |
[React-Native ๊ธฐ์ด ๊ฐ์] Button (0) | 2021.07.19 |
[React-Native ๊ธฐ์ด ๊ฐ์] React Native Component / Style (0) | 2021.07.18 |
[React-Native ๊ธฐ์ด ๊ฐ์] ํ๋ฉด ์ถ๋ ฅ & State (0) | 2021.07.16 |
Comments