Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

history replace throws errors #76

Closed
ahmedu007 opened this issue May 1, 2018 · 8 comments
Closed

history replace throws errors #76

ahmedu007 opened this issue May 1, 2018 · 8 comments
Assignees
Projects

Comments

@ahmedu007
Copy link
Contributor

Do you want to request a feature or report a bug?
Report a bug

What is the current behavior?
If the current behaviour is a bug, please provide necessary steps for reproduction of this issue, or better the reduced test case (without any external dependencies, if possible).

  1. Okay so this error is really weird. Probably needs a bit more testing but its hard to reproduce it for even myself. I have history prop available in my component and I can use this.props.history.push('/login') without any issues.

As soon as i change push to .replace I get this error

TypeError: undefined is not an object (evaluating 'scenes[targetSceneIndexInScenes].index')

This error is located at:
    in CardStack (at DefaultRenderer.js:137)
    in RCTView (at View.js:78)
    in View (at Transitioner.js:192)
    in Transitioner (at DefaultRenderer.js:151)
    in DefaultRenderer (at Navigation.js:42)
    in CardStack (created by Route)
    in Route (created by withRouter(CardStack))
    in withRouter(CardStack) (at Navigation.js:39)
    in Navigation (at App.js:58)
    in Router (created by MemoryRouter)
    in MemoryRouter (at NativeRouter.js:11)
    in NativeRouter (at App.js:57)
    in RCTView (at View.js:78)
    in View (at App.js:56)
    in ThemeProvider (at App.js:55)
    in App (created by Connect(App))
    in Connect(App) (at App.js:11)
    in Provider (at App.js:10)
    in NativeApp (at registerRootComponent.js:35)
    in RootErrorBoundary (at registerRootComponent.js:34)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:78)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:78)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:34)

I can use replace on most of my components in the app, but some places this error just persists and I'm struggling to clear history and block the user to go back to the screen they're not authorised to go back to.

What is the expected behavior?
Clear the last page and stop user from navigating back to it

Environment (include versions). Did this work in previous versions?

  • Device: macOS
  • OS: iOS emulator running iOS 11.3
  • React-Native (version): ^0.54.2
  • React-Router (version): ^4.2.0
  • React-Router-Navigation (version): ^1.0.0-rc.4
@ahmedu007
Copy link
Contributor Author

Any suggestions, advice, instructions would be appreciated :)

@LeoLeBras
Copy link
Member

Hi @ahmedu007 !
I'm facing similar issues with actual version of react-router-navigation. I'm fixing a lot of bugs on the dev branch including this one.
A stable version of the library should be released soon. 🙏

@LeoLeBras LeoLeBras self-assigned this May 2, 2018
@LeoLeBras LeoLeBras mentioned this issue May 2, 2018
18 tasks
@ahmedu007
Copy link
Contributor Author

Any progress on this issue?

@ahmedu007
Copy link
Contributor Author

Something I've noticed that this error is also thrown whenever the transition isn't completed and another button or the link is pressed.

@LeoLeBras LeoLeBras added this to To do in v2 Oct 11, 2018
@LeoLeBras
Copy link
Member

Hey @ahmedu007 ,
Many changes have been made recently. Do you still have the error with the new alpha versions? If so, do you have an example (or a Github) repo that reproduces the issue?

@ahmedu007
Copy link
Contributor Author

Hi @LeoLeBras

Thanks for the response. The issue was fixed in alpha .6 but there was something else that wasnt working correctly in .7
We are staying on alpha.06 for now. I'll try to see if I can get around to replicate the issue, and give you more feedback. It was something along the lines of the state.params not being passed correctly or something.

@ahmedu007
Copy link
Contributor Author

We can close this issue, as it seems to be working without any bugs for this specific case. Thankyou for all the efforts 💯

@LeoLeBras
Copy link
Member

Okay, don't hesitate to send me a minimal repo to reproduce this issue !

@LeoLeBras LeoLeBras moved this from To do to Done in v2 Nov 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
v2
  
Done
Development

No branches or pull requests

2 participants