-
Notifications
You must be signed in to change notification settings - Fork 1
Book TypesSript #7
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| interface Props { | ||
| onPress: () => void; | ||
| backButton: number; |
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 there is an ImageType from react-native. Check it out or leave it like this
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.
Alright, I'll look into it 👀
|
|
||
| interface Props { | ||
| scene: { | ||
| descriptor: { options: { title?: string; headerStyle?: { height: number }; hasBackBtn?: boolean } }; |
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.
when you declare types for styles you can use ViewStyles instead of writing each one
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.
Interesting. Didn't know that one!
| scene: { | ||
| descriptor: { options: { title?: string; headerStyle?: { height: number }; hasBackBtn?: boolean } }; | ||
| }; | ||
| navigation: { goBack(): void }; |
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 there are interfaces from react-navigation, https://reactnavigation.org/docs/4.x/typescript
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'll check the doc
| const { | ||
| options: { title, headerStyle } | ||
| } = scene.descriptor; | ||
| const { height } = headerStyle!; |
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.
why are you doing this? Do you only want the height and nothing else?
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.
Yes, I just want the height to get the height set in screenOptions. I could just define within the header's styles, but according to the doc (or what I read from it) it is best to set it from screenOptions so both the custom and the default header have the same height
| import { APP_OPTIONS, LOGIN_OPTIONS } from './constants'; | ||
|
|
||
| interface Props { | ||
| token: string | 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.
token?: string; or you receive null's sometimes?
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.
The default value for the token, inside the globalState, is null. So I would always get a value: string | null. I thought of setting undefined in the globalState and set token? instead, but as a good practice I don't like to set undefined manually.
| const { data: response, loading } = useRequest<Response>(getBook, { id }); | ||
| const { image, title, author, year, genre } = response?.data || DEFAULT_BOOK; | ||
| return ( | ||
| <BookDetail image={image} title={title} author={author} year={year} genre={genre} isLoading={loading} /> |
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 could directly destruct in here with ...data and declare data as above
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.
Alright! 👍
Summary
tsconfig.jsfile with all the relevant config needed for TS.index.d.tsfile to be able to import.pngfilesuseLazyRequestanduseRequestHooks. Same withwithLoaderhook.as constScreenshots
iPhone X
iPhone 8
iPhone 7
Pixel 3XL
Pixel 3
Pixel 2
Trello Card
https://trello.com/c/MwfBmj9p/54-typescript-ii-pr%C3%A1ctica