-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add snacks to api reference docs #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add snacks to api reference docs #616
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice. Thanks!
```js | ||
import { CommonActions } from '@react-navigation/native'; | ||
|
||
navigation.dispatch(CommonActions.setParams({ title: 'Hello' })); | ||
navigation.dispatch(CommonActions.setParams({ user: 'Wojtek' })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤟
onPress={() => | ||
navigation.setParams({ | ||
friends: | ||
route.params.friends[0] === 'Brent' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤝
<DrawerItemList {...props} /> | ||
<DrawerItem | ||
label="Close drawer" | ||
onPress={() => navRef.current.dispatch(DrawerActions.closeDrawer())} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe useNavigation()
and then just openDrawer()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also get navigation
in props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use navigation from props then :)
} from '@react-navigation/drawer'; | ||
import { DrawerActions } from '@react-navigation/routers'; | ||
|
||
const navRef = React.createRef(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
} from '@react-navigation/drawer'; | ||
import { DrawerActions } from '@react-navigation/routers'; | ||
|
||
const navRef = React.createRef(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more things
@@ -22,6 +22,7 @@ function Notifications({ navigation }) { | |||
title="Go to Profile" | |||
onPress={() => navigation.navigate('Profile')} | |||
/> | |||
<Button title="Go Back" onPress={() => navigation.goBack()} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just navigation.goBack
navigation.addListener('focus', () => alert('Screen was focused')) | ||
); | ||
|
||
React.useEffect(() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add array as a second arg (not only here)
function ProfileScreen({ navigation }) { | ||
return ( | ||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | ||
<Button title="Go back" onPress={() => navigation.goBack()} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
} | ||
|
||
export default function App() { | ||
enableScreens(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it’s more common to do it in global scope
docs/material-top-tab-navigator.md
Outdated
@@ -270,6 +274,7 @@ function MyTabBar({ state, descriptors, navigation, position }) { | |||
}); | |||
}; | |||
|
|||
const inputRange = [0, 1, 2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep it in sync with number of tabs, I'd do
const inputRange = [0, 1, 2]; | |
const inputRange = state.routes.map((_, i) => i); |
<DrawerItemList {...props} /> | ||
<DrawerItem | ||
label="Close drawer" | ||
onPress={() => navRef.current.dispatch(DrawerActions.closeDrawer())} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also get navigation
in props
2581168
to
45d7739
Compare
Added snacks to almost all examples and fixed some typos etc.