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

180
Visualizações
Using children along with react-redux (React typesciprt)

A componenet VerifiedComp renders children if the email is verified(a prop from redux). If the email is not verified than it displays a button. The problem that I am having is that typescript is asking for children in the Parent Component.

Here is the CreatePage Component which is the parent component.

type StateTypes = {
  history: { push: (link: string) => {} };
};

const mapStateToProps = ({ history }: StateTypes) => ({
  history,
});

const connector = connect(mapStateToProps, { startCreateMovie });
type PropsFromRedux = ConnectedProps<typeof connector>;

export const CreatePage = ({ history, startCreateMovie }: PropsFromRedux) => {
  return (
    <VerifiedComp>
      <CreateForm ... />
    </VerifiedComp>
  );
};

And here is the VerifiedComp.

type PropTypes = {
  children: React.ReactNode
};

type StateTypes = {
  auth: { user: { emailVerified: boolean }, providerData: {email: string} };
}

const mapStateToProps = (state: StateTypes, props: PropTypes) => ({
  email: state.auth.providerData.email,
  children: props.children,
  emailVerified: state.auth.user.emailVerified
});

const connector = connect(mapStateToProps);
type PropsFromRedux = ConnectedProps<typeof connector>;

const VerifiedComp: React.FC<PropsFromRedux> = (props: PropsFromRedux) => {
  return props.emailVerified ? (
    <React.Fragment>{props.children}</React.Fragment>
  ) : (
    <Box>.....</Box>
  )

Here is the complete problem

Type '{ children: Element; }' is missing the following properties from type '{ email: string; emailVerified: boolean; }': email, emailVerified  TS2739

    19 | export const CreatePage = ({ history, startCreateMovie }: PropsFromRedux) => {
    20 |   return (
  > 21 |     <VerifiedComp>
       |      ^
    22 |       <MovieForm
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It's because you have made children property as mandatory

type PropTypes = {
children: React.ReactNode
};

instead make it optional as below:

type PropTypes = {
children?: React.ReactNode
};
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