Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
Error: React Hook "useCallback" se llama condicionalmente. Los React Hooks deben llamarse exactamente en el mismo orden en cada renderizado de componente

Obtener un gancho de devolución de llamada de uso de error de compilación llamado condicionalmente. si no uso useCallback obtengo el error Los accesorios JSX no deberían usar funciones de flecha

 const LinkComp = <T extends {}>(props: LinkProps & T extends AnchorProps ? AnchorProps : ButtonProps) => { const { title, hideTitle, children, url = '', action, label, newWindow, className, iconName, isExternal, inheritColor = true, underlineOnHover = true, underline = false, theme = '', bold = false, onClick, modal = false, forceAnchorTag = false, appendQueryParams = true, showOutline = true, ...linkProps } = props; const [handleClick] = useRouter(action, url); const forwardedParams = useSelector(selectForwardedQueryParams); const linkContent = ( <> {iconName && <Icon name={iconName} className='mr-3' />} {!hideTitle && (title || children)} </> ); if (modal) { if (linkProps.modalTitle) delete linkProps.modalTitle; return ( <button {...(anchorProps as ButtonProps)} role='link' onClick={onClick as ButtonProps['onClick']}> {linkContent} </button> ); } // queryString.stringifyUrl combines the params from both url and forwarded params. // don't append the params for `tel` links const forwardedParamsUrl = queryString.stringifyUrl({ url, query: !url?.includes('tel:') && forwardedParams }); const handleAnchorClick = useCallback((e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { if (handleClick) handleClick(e); return true; },[handleClick]); if (forceAnchorTag) { return ( <a href={forwardedParamsUrl} {...(anchorProps as AnchorProps)} onClick={handleAnchorClick}> {linkContent} </a> ); } // search extras uses the query params in a different way, so no need to append them here const fullUrl = appendQueryParams ? forwardedParamsUrl : url; return ( <Link href={fullUrl} passHref={isExternal || newWindow}> <a {...(anchorProps as AnchorProps)} onClick={handleClick}> {linkContent} </a> </Link> ); }; export default LinkComp;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe mover su definición de useCallback arriba de la verificación if (model) . Este bloque if puede hacer que su componente se renderice antes de que useCallback haya memorizado la función.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!