Skip to content

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

Merged
merged 2 commits into from
Jan 23, 2020

Conversation

WoLewicki
Copy link
Member

Added snacks to almost all examples and fixed some typos etc.

@WoLewicki WoLewicki requested review from osdnk and satya164 January 22, 2020 14:27
Copy link
Member

@osdnk osdnk left a 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' }));
Copy link
Member

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'
Copy link
Member

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())}
Copy link
Member

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()

Copy link
Member

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

Copy link
Member Author

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Member

@osdnk osdnk left a 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()} />
Copy link
Member

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(() =>
Copy link
Member

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()} />
Copy link
Member

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();
Copy link
Member

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

@@ -270,6 +274,7 @@ function MyTabBar({ state, descriptors, navigation, position }) {
});
};

const inputRange = [0, 1, 2];
Copy link
Member

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

Suggested change
const inputRange = [0, 1, 2];
const inputRange = state.routes.map((_, i) => i);

<DrawerItemList {...props} />
<DrawerItem
label="Close drawer"
onPress={() => navRef.current.dispatch(DrawerActions.closeDrawer())}
Copy link
Member

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

@WoLewicki WoLewicki force-pushed the @wolewicki/add-snacks-to-api-reference-docs branch from 2581168 to 45d7739 Compare January 23, 2020 11:05
@WoLewicki WoLewicki merged commit 3d11d94 into source Jan 23, 2020
@satya164 satya164 deleted the @wolewicki/add-snacks-to-api-reference-docs branch February 23, 2020 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants