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.

Home.navigationOptions dosn't work with components being passed through firebase context

See original GitHub issue

changing navigation options when passing the component though the context api dosn’t work.

Apps.navigationOptions = { title: 'Apps' } export default withFirebaseHOC(Apps)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
amandeepmittalcommented, Mar 22, 2020

Hey @iamwill123

Apologies for getting back to you on so late. Feel free to submit a PR on this. However, do note that, in future, I will be upgrading react-navigation to v5 and thus, the firebase auth methods consumption might change.

A big thank you for the above solution ❤️

0reactions
iamwill123commented, Nov 14, 2019

@jim-alexander I believe this will help as I had this same question and issue. I did some digging and adapted some code into this:

context.js:

import React, { createContext } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';

const FirebaseContext = createContext({});

export const FirebaseProvider = FirebaseContext.Provider;

export const FirebaseConsumer = FirebaseContext.Consumer;

export const withFirebaseHOC = Component => {
  const Wrapper = props => {
    return (
      <FirebaseConsumer>
        {state => <Component {...props} firebase={state} />}
      </FirebaseConsumer>
    );
  };
  hoistNonReactStatics(Wrapper, Component);
  return Wrapper;
};

The key was coping the static methods by using the hoist-non-react-statics package. This solved my static navigationOptions issue on each screen.

References for the solution: https://kentcdodds.com/blog/mixing-component-patterns https://www.npmjs.com/package/hoist-non-react-statics https://reactjs.org/docs/higher-order-components.html#static-methods-must-be-copied-over

@amandeepmittal, this might be a worthwhile PR. I have a few more additions to this starter which is awesome by the way.

Hope it helps, Will

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Navigation with Login Screen - Stack Overflow
Be inside a component adding code, where you have this.props.navigation available · Make a component like <Something /> · Pass navigation into it, ......
Read more >
Function to set this.state.isLoading to false doesn't work inside ...
Coding example for the question Function to set this.state.isLoading to false doesn't work inside navigationOptions-React Native.
Read more >
Troubleshooting | React Navigation
Troubleshooting. This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation.
Read more >
navigation.navigate is undefined - You.com | The Search Engine ...
So, your problem is conceptual here. React components receive a single object, named props , that contains all the props . Normally, you...
Read more >
Navigate to a destination - Android Developers
Navigating to a destination is done using a NavController , an object that manages app navigation within a NavHost .
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