-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent typescript error for conditional tabs
- Loading branch information
1 parent
c79f361
commit 749c27b
Showing
5 changed files
with
64 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { useState } from 'react' | ||
import { View, Text, StyleSheet } from 'react-native' | ||
import { TouchableOpacity } from 'react-native-gesture-handler' | ||
|
||
import { TabBarProps } from '../../src/types' | ||
import ExampleComponent from './Shared/ExampleComponent' | ||
import { ExampleComponentType } from './types' | ||
|
||
const title = 'Conditional Tabs' | ||
|
||
const HEADER_HEIGHT = 200 | ||
|
||
const NewHeader: React.FC< | ||
TabBarProps & { | ||
setHideArticleTab: React.Dispatch<React.SetStateAction<boolean>> | ||
} | ||
> = (props) => { | ||
return ( | ||
<View pointerEvents="box-none" style={styles.headerView}> | ||
<TouchableOpacity | ||
onPress={() => props.setHideArticleTab((prev) => !prev)} | ||
> | ||
<Text>Toggle articles tab</Text> | ||
</TouchableOpacity> | ||
</View> | ||
) | ||
} | ||
|
||
const DefaultExample: ExampleComponentType = () => { | ||
const [hideArticleTab, setHideArticleTab] = useState(false) | ||
return ( | ||
<ExampleComponent | ||
renderHeader={(props) => ( | ||
<NewHeader setHideArticleTab={setHideArticleTab} {...props} /> | ||
)} | ||
headerHeight={HEADER_HEIGHT} | ||
hideArticleTab={hideArticleTab} | ||
/> | ||
) | ||
} | ||
|
||
DefaultExample.title = title | ||
|
||
export default DefaultExample | ||
|
||
const styles = StyleSheet.create({ | ||
headerView: { | ||
height: HEADER_HEIGHT, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters