-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[v4] Add usePolaris/AppBridge #1482
Conversation
@@ -9,6 +9,7 @@ export { | |||
default as AppProvider, |
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.
Need to use these in src/hooks
and we can't dive into component folders from outside /components
@@ -0,0 +1,10 @@ | |||
import * as React from 'react'; |
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.
We'll want this to expose appBridge
rather than exporting usePolaris
} | ||
|
||
mountWithAppProvider(<Component />); | ||
expect(JSON.stringify(context)).toEqual( |
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.
Feel odd about this test. But we've done it before and I can't think of a better alternative.
I'm a little late to the party on this one but I've got a thought: Hooks should be pretty small and self contained - each hook would never sprawl across multiple files (unlike components that may have partner scss files and things like that). As such I don't think there's any value in creating a "folder per hook" hierarchy as there's only ever going to be one file (+ the test) for each hook within it. With that in mind I don't think there's any value in having |
WHY are these changes introduced?
Preparing for hooks
WHAT is this pull request doing?
src/hooks
usePolaris
hook for internal useuseAppBridge
hook for external use🎩
Trust in the powers of tests or try the playground - you'll need credentials for testing
useAppBridge
Copy-paste this code in
playground/Playground.tsx
: