-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
packages/example/src/index.tsx
Outdated
@@ -41,6 +46,8 @@ const PERSISTENCE_KEY = 'NAVIGATION_STATE'; | |||
Asset.loadAsync(StackAssets); | |||
|
|||
export default function App() { | |||
const containerRef = React.useRef<NavigationContainerRef>(React.createRef()); |
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 don't need to pass createRef
into useRef
, we can pass null and use the returned ref instead of .current
@@ -162,7 +167,7 @@ const Container = React.forwardRef(function NavigationContainer( | |||
"Any 'setState' calls need to be done inside 'performTransaction'" | |||
); | |||
} | |||
|
|||
wasStateModified.current = true; |
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.
shouldn't we check if state actually changed?
packages/example/package.json
Outdated
@@ -17,6 +17,7 @@ | |||
"eject": "expo eject" | |||
}, | |||
"dependencies": { | |||
"@navigation-ex/native": "^0.0.1", |
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 this will create a symlink, right? if just add it to the eslint config in root
if (castedRef.current !== null) { | ||
castedRef.current | ||
.dispatch({ type: 'GO_BACK' }) | ||
.then((wasHandled: 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.
Use async/await maybe :)
I have another thought. This wouldn't be a problem for us if we had a some kind of When you call this method, it'll recursively call parent Similar to how the root container's Now we can check this method in our container and only dispatch a back action if we can go back. No messing with how state updates, no returning promise from dispatch etc. |
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
+ Coverage 96.3% 96.31% +<.01%
==========================================
Files 24 24
Lines 406 407 +1
Branches 87 87
==========================================
+ Hits 391 392 +1
Misses 14 14
Partials 1 1
Continue to review full report at Codecov.
|
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.
It's a bit hard to review with both changes in this PR. Can you rebase your PR and squash the commits so that there is a single commit for changes made only in this PR which I can easily review?
Or let's get the other PR merged first and rebase.
packages/native/src/index.tsx
Outdated
|
||
export { useBackButton }; | ||
|
||
export default function useNativeIntegration(ref: NavigationContainerRef) { |
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.
move the hook to separate file since we only re-export in index
files everywhere
|
||
React.useImperativeHandle(ref, () => ({ | ||
performOnFocusedNavigator: ( |
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.
Don't think we want to expose performOnFocusedNavigator
. The exposed ref should look like every other navigation object. We should expose canGoBack
method instead where we internally perform this on focused navigator and return the result.
0883d97
to
e202be4
Compare
e202be4
to
a971f37
Compare
No description provided.