score:0
you would need to use context api. i have made a gist that have a simple approach for that.
there is a simple mistake you are making
you can import a method from a class
import { onloggedout } from '../app/app';
import { app } from '../app/app';
i'm not sure how you are doing this import, but
- if
onloggedout
is insideapp
, you can't do that type of import. - if
onloggedout
is outsideapp
, it would never work, because it usesthis.setstate
.
you need to some something that is called lifting state up
, but for authentication, it's better to use context api. i have made a gist (it's kind of the same, but better for your case).
Source: stackoverflow.com
Related Query
- How do I call a method from another class component in React.js
- How can I call a component's method from another component in React?
- How to call child component method from parent component in react?
- How to call a component method from another component?
- React/ES6 -> How to call an React component class method from another component?
- How to call child component's method from a parent component in React
- How to call child component method from parent
- ReactJS. How to call component's method from parent component
- How do I export or call method from component in another component in react?
- how do you call a method from another react class component
- React JS: How to call a validation method of a custom Input component from its Parent
- How to call onFinish method of form in child component from parent in ant design framework
- How to call an API of another child component from a grand child of a parent component in react js
- How to call child submit method from another child component
- How to call functional child component method from class parent component
- How to call a method of a functional react component from another functional react component?
- ReactJS - Call One Component Method From Another Component
- How do I call setState from another Component in ReactJs
- Call child component method from parent component in reactjs
- How to call a static method from another static method in React?
- how to call function of child in functional component from parent in react.js?
- How to call another component from onClick function in ReactJS
- Can't call child component method from parent component in React Native
- How does one React component call a method in another React component?
- How to call a Parent method in Child Component using Hook (ForwardRef concept)
- Call child component method from parent in react
- how to call a child component from parent component in electron-es6-react
- In React, how do I call a function in one component (which is being rendered with React Router) from another component?
- How to call React/Typescript child component function from parent component?
- How to call method in child component only once after parent state update
More Query from same tag
- Mapping Object Array Data in Redux
- How do I pass props from Child to Parent in React for incremental onClick?
- JSX Converter using React.createElement("h1", null) instead of React.DOM.h1(null)
- Accessing Django MEDIA_URL and MEDIA_ROOT setting.py values from ReactJS frontend
- How can I get the coordinates of a given element in react tsx
- React-Loadable SSR with Webpack 4 and Babel 7
- JavaScript/React Auto-filling other fields based one the first one
- Why my Tailwind components library 'FlowBite' is not working?
- How can i get the context of the MUI theme?
- How to make my form data appear on the console after I submit the form?
- Error when rendering React Portal with Storyshots
- ReactJS - react-router nested path not rendered
- bootstrap progress bar doesn't render inside react component
- How to consume BehaviorSubject in React app
- Are variables destructured from useState unusable above a return statement?
- Styling create-row input elements in Material Table
- How do I use the type of imported JSON file in TypeScript
- React Antd - Found 2 elements with non-unique warning
- Navlink - React Router Dom not working in React.Js
- Why are my React components not re-rendering on setState()?
- How to fix problem with "Uncaught Error: unknown type: dragstart"
- React-virtualized List selected item styling only fire when scroll up
- import is not defined erorr using es6
- How to pass params from laravel to ReactJS?
- Cant find the length of my array in react-bootstrap
- Is there a create-react-app alternative for Preact?
- Reactjs sweetalert2 put input above html
- How to extract data from nested json in react
- Using React To Create a Loop That Updates A Number Value
- onClick post request and redirect to another page