这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@yulolimum
Copy link
Member

Please verify the following:

  • yarn test jest tests pass with new tests, if relevant
  • README.md has been updated with your changes, if relevant

Describe your PR

  • Refactors @carlinisaacson useSafeAreaInsetPadding hook into a new useSafeAreaInsetsStyle shared hook.
  • Updates Screen, Header, WelcomeScreen, DemoShowroomScreen to use the new useSafeAreaInsetsStyle hook instead of <SafeAreaView/>.
  • Adds new "Utils" documentation.
    • Adds useHeader documentation.
    • Adds useSafeAreaInsetsStyle documentation.
  • Updates Header documentation with "Usage" examples.
  • Updates Screen documentation.

Closes #2300. Thanks to @ryskin for the ideas.

Proofs

useSafeAreaInsetsStyle Documentation useHeader documentation Header usage documentation
yulolimum-capture-2022-11-16--16-12-59 yulolimum-capture-2022-11-16--16-12-00 yulolimum-capture-2022-11-16--16-14-11

Copy link
Contributor

@frankcalise frankcalise left a comment

Choose a reason for hiding this comment

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

Nice work! The changes look good to me!

I'd vote to make a hooks dir and move the following from utils there:

  • useHeader.tsx
  • useSafeAreaInsetsStyle.ts
  • isMounted.ts and rename to useIsMounted.ts

and maybe add an index.ts for exports?

Low gafo but utils I think of storage, date functions etc and feel like hooks is more direct where to find them.

Thoughts?

@yulolimum
Copy link
Member Author

Low gafo but utils I think of storage, date functions etc and feel like hooks is more direct where to find them.

@frankcalise I have a low-gafo too. I prefer to have the fewest amount of folders possible. With the use prefix, they'd already be grouped together anyways. Maybe query the team?

await episodeStore.fetchEpisodes()
setIsLoading(false)
})()
}, [episodeStore])
Copy link
Member

@jamonholmgren jamonholmgren Nov 17, 2022

Choose a reason for hiding this comment

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

Not relevant to this PR, but this makes me think, wouldn't it be nice to have a useLoadingEffect custom hook?

Something like...

const loading = useLoadingEffect(async () => {
  await episodeStore.fetchEpisodes()
}, [episodeStore])

It then handles the isLoading state under the hood, maybe.

Just TOL, not for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

A lot of querying libraries already do that. mst-query, react-query, urql, etc.. Since we don't use that, it might be cool to have a generic hook for any promises (something like this: https://github.com/bsonntag/react-use-promise#usage).

Also, isn't react coming out with use() hook that will have something simiarl?

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

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

Looks great. One comment about the useHeader example.

Comment on lines 258 to 261
useHeader({
headerShown: true,
header: () => <Header title="Hello" />,
})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
useHeader({
headerShown: true,
header: () => <Header title="Hello" />,
})
useHeader({
title: "Hello",
})

The API of this useHeader is you just pass in the props, I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, my mistake.. copy pasting stuff is hard.

@@ -0,0 +1,34 @@
# Collection of helpful utilities

Here you can find a library of utilities that are used often within your application. This includes hooks, helper functions, and various tools.
Copy link
Member

Choose a reason for hiding this comment

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

I miss the humor we used to inject in these things.

Suggested change
Here you can find a library of utilities that are used often within your application. This includes hooks, helper functions, and various tools.
Here you can find a library of utilities that are used often within your application next to the stapler, tape, scissors and migraine meds. This includes hooks, helper functions, and that thing from that wedding.

(Don't accept this...lol)

@yulolimum yulolimum merged commit 57fe816 into master Nov 17, 2022
@yulolimum yulolimum deleted the feat/header-related-updates branch November 17, 2022 22:35
@infinitered-circleci
Copy link
Collaborator

🎉 This PR is included in version 8.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Demo with real use of Header

5 participants