Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Variable export without function call

I am trying to export a variable that gets updated from state. The challenge I have is that I cannot modify how the variable is being exported, as it is being used in way too many files at the moment.

Maybe can call the function from another file to execute?

import { useAppDispatch, useAppSelector } from "../redux/hooks";
    
export const Content = () => {
  const { store } = useAppSelector((state) => state.StoreReducer);
  return store;
};

export const currency =
  Content() && Content()?.currency ? Content()?.currency : "USD";

export default {
  CURRENCY: currency}

React Error:

Invalid hook call. Hooks can only be called inside of the body of a function component. 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The error message is clear, react hooks can only be called inside of the body of a function component. But you are calling the Content function in a module scope. You can get the whole state by using store.getState().

import store from '<somewhere>/store';

export const Content = () => {
  const { store } = store.getState().StoreReducer;
  return store;
};

export const currency =
  Content() && Content()?.currency ? Content()?.currency : "USD";

export default { CURRENCY: currency }
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda