How to use the react-firebase-hooks/auth.useAuthState function in react-firebase-hooks

To help you get started, we’ve selected a few react-firebase-hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github equithon / site-main / src / utils / siteAuth.js View on Github external
export const accessIfAuthenticated = Component => props => {
  let AugmentedComponent;
  const { state: { firebase } } = useContext(SiteContext);
  const { initialising, user } = useAuthState(firebase.auth);
  const userLoggedIn = !initialising && (user !== null);

  if(initialising) {
    AugmentedComponent = withCurUserInfo()({});
  }
  else if(userLoggedIn) {
    AugmentedComponent = withCurUserInfo(Component)(props);
  }
  else {
    console.warn("Whoops! You're not logged in. If this is an error or a bug, please email alex@equithon.org.")
    AugmentedComponent = withCurUserInfo()({ redirect: true });
  }


  return AugmentedComponent;
};
github bmcmahen / captioner / src / App.tsx View on Github external
export const App: React.FunctionComponent = props => {
  const { initialising, user } = useAuthState(firebase.auth());

  return (
github bmcmahen / julienne / src / App.tsx View on Github external
function App() {
  const { initialising, user } = useAuthState(firebase.auth());

  if (initialising) {
    return (
      <div style="{{">
        
      </div>
    );
  }

react-firebase-hooks

React Hooks for Firebase

Apache-2.0
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis