Conversation
|
|
||
| interface Props { | ||
| onPress: () => void; | ||
| backButton: number; |
There was a problem hiding this comment.
i think there is an ImageType from react-native. Check it out or leave it like this
There was a problem hiding this comment.
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.
when you declare types for styles you can use ViewStyles instead of writing each one
There was a problem hiding this comment.
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.
i think there are interfaces from react-navigation, https://reactnavigation.org/docs/4.x/typescript
There was a problem hiding this comment.
I'll check the doc
| const { | ||
| options: { title, headerStyle } | ||
| } = scene.descriptor; | ||
| const { height } = headerStyle!; |
There was a problem hiding this comment.
why are you doing this? Do you only want the height and nothing else?
There was a problem hiding this comment.
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.
token?: string; or you receive null's sometimes?
There was a problem hiding this comment.
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.
you could directly destruct in here with ...data and declare data as above
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