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 | 31 |
Tags
- 리액트
- C++98에러
- 순열
- modal
- react-native
- 리액트 네이티브
- asyncstorage
- 뒤로가기구현
- 모달
- makePermutation
- Icon
- 페이지리렌더링
- 2023년 정처기 필기
- React
- 재귀함수
- ReactNative
- 리액트네이티브
- vision-camera
- touchableopacity
- JSON
- fcm push
- algorithm
- 가격자릿수
- TextInput
- API
- fcm 푸시
- Flatlist
- 자동로그인
- 알고리즘
- 모달에서뒤로가기
Archives
- Today
- Total
생각은 길게 코딩은 짧게
[React-Native]Floating Button 구현 본문
728x90
상품 리스트를 보다 상품등록을 원할 때 바로 갈 수 있게 플로팅 버튼을 구현해보았습니다!
✅ Plus 아이콘 ( AntDesign) 사용
import Icons from 'react-native-vector-icons/AntDesign';
✅ stack class에 이동할 페이지 선언 ( AddGoods)
class Stack extends Component {
render() {
return (
<NativeStack.Navigator initialRouteName="Login"
screenOptions={{
headerTitleAlign: 'center',
}}>
<NativeStack.Screen name="AddGoods" component={AddGoods}
options={{ title: "" }} />
</NativeStack.Navigator>
);
}
}
✅ 버튼 클릭 시 상품등록 페이지로 이동
<TouchableOpacity style={styles.floatingbtn} onPress={()=>{this.props.navigation.navigate("AddGoods")}}>
<Icons name='plus' size={30} color='white' />
</TouchableOpacity>
💡 onpress={this.props.navigation.navigate("AddGoods"} 방식으로 할 경우
Warning: Cannot update a component (`ForwardRef(BaseNavigationContainer)`) 의 오류가 뜹니다
동시에 두 개의 렌더링을 수행하려면 다음과 같이 화살표를 추가하면 됩니다
onPress={()=>{this.props.navigation.navigate("AddGoods")}
✅ Floating Button CSS
floatingbtn:{
borderWidth: 1,
borderColor: 'rgba(0,0,0,0.2)',
alignItems: 'center',
justifyContent: 'center',
width: 50,
position: 'absolute',
bottom: 5,
right: 10,
height: 50,
backgroundColor: 'black',
borderRadius: 100,
}
'React Native' 카테고리의 다른 글
[React-Native] ActivityIndicator ( 로딩화면 ) (0) | 2023.01.02 |
---|---|
[React-Native] 버튼 활성화/비활성화 (0) | 2022.12.21 |
[React-Native] TextInput value state값으로 가져오기 (0) | 2022.12.13 |
[React-Native] 자동 로그인 구현 (0) | 2022.12.02 |
[React-Native] TextInput 값 비우기 (0) | 2022.12.02 |