Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
Returning Code from a TypeScript Module in React

I am trying to create a simple page which two main parts: Menu and Guide. In my App,tsx, I have:

import React from 'react';
import Guide from './Guide/Guide';
import './App.css';

function App() {
  return (
    <Guide />
  );
}

export default App;

This is fine.

But, in the ./Guide/Guide.tsx, I have:

import React, { Component } from "react";
import Menu from "./Menu/Menu";

export default class Guide extends Component {
    constructor(props: {}) {
        super(props);
    }

    return (
        <Menu />
    );
}

Menu.tsx:

import React, { Component } from "react";

export default class Menu extends Component {
    return (
        <h1>Test</h1>
    );
};

However I'm getting the error 'return', which lacks return-type annotation, implicitly has an 'any' return type..

What's going on here?

You can probably tell I'm very new to React and TypeScript!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In class component (such as your Guide and Menu components), you render some HTML code inside the render function. Insinde functional components (such as your App component), you render some HTML code inside the return function. Here you are mixing those 2 different syntax, that is why you are getting this error.

In order to fix this, simply replace your return function in the Menu and Guide components by the render function

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda