question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-Navigation (instead of Navigator) Compatibility

See original GitHub issue

I am writing a project that navigates using react-navigation and i want to use lightbox however lightbox requires Navigator to function properly. I was hoping to see if i could write react-navigation support into the component and then allow a PR to happen. The possibility in my mind is using Navigator + react navigation so that i dont have to re-make my navigation because you could have both “this.props.navigator” and “this.props.navigation” but i am not sure how some of the navigation functions work.

I have been looking into lightbox.js at the occurences of Navigator and i am searching through the react-navigation api to see if i can find replacements for the functions used as it only occurs 8 times (2 of which are just checks to see if navigator is present).

lightbox.js - navigator occurences (cant get the formatting right)

’ open: function() { this._root.measure((ox, oy, width, height, px, py) => { this.props.onOpen();

        this.setState({
          isOpen: (this.props.navigator ? true : false),
          isAnimating: true,
          origin: {
            width,
            height,
            x: px,
            y: py,
          },
        }, () => {
          if(this.props.navigator) {`

create a route that will work with navigation (for react-navigation it would be the navigationOptions)

var route = { component: LightboxOverlay, passProps: this.getOverlayProps(), };

fetch the current set of routes

var routes = this.props.navigator.getCurrentRoutes();

push a route onto the stack

routes.push(route);

some sort of reset for the stack that Navigator does (still looking into it, any help knowing what this does would be nice.

this.props.navigator.immediatelyResetRouteStack(routes);

Then the rest of the code for opening the lightbox runs

} else { this.setState({ isOpen: true, }); } this.setTimeout(() => { this.state.layoutOpacity.setValue(0); }); }); }); },

for closing the stack the same lines are called but with .pop() instead of .push()

Anyone with experience of both react-navigation and react-native-lightbox would be a great help.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
acomitocommented, Jul 27, 2017

No @nuttylord I ended up avoiding a lightbox in the app for now.

0reactions
acomitocommented, Sep 3, 2017

I was able to get it working with react-navigation by just passing navigator={null}

My only issue was the exit animation was a little weird (images were in a sort of 3 column grid/rows via flexbox). But I think that was just flexbox not your package?

react-navigation was suppose to add “shared element transitions”, but not sure where that’s at. I would think that could be used to build a lightbox pretty easily.

https://github.com/react-community/react-navigation/issues/175

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compatibility layer - React Navigation
The compatibility layer handles various API differences between React Navigation 4 and 5: Use static configuration API of v4 instead of the component...
Read more >
A complete guide to React Navigation 5 - LogRocket Blog
React Navigation is a library consisting of components that makes building and connecting screens in React Native easy.
Read more >
Upgrade React-navigation from V4.x.x to V5.x.x - Stack Overflow
When we redirect on this navigator we have some errors coming from withNavigation (in compat mode) and navigationOptions . withNavigation: The ...
Read more >
Routing and Navigation - Expo Documentation
React Navigation includes support for common navigation patterns, and it's fully customizable so you can achieve any navigation pattern, even if it's not...
Read more >
Getting Started with Stack Navigator Using react ... - Heartbeat
Just recently, the 5th stable version of the React Navigation library was released. Without a doubt, it's one of the most popular navigation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found