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

183
Views
Uso de niños junto con react-redux (React typeciprt)

Un componente VerifiedComp representa children si el correo electrónico está verificado (un accesorio de redux). Si el correo electrónico no está verificado, muestra un botón. El problema que tengo es que el mecanografiado solicita niños en el componente principal.

Aquí está el componente CreatePage , que es el componente principal.

 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> ); };

Y aquí está el 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> )

aqui esta el problema completo

 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 answers
Answer question

0

Es porque has hecho que la propiedad de los niños sea obligatoria.

 type PropTypes = { children: React.ReactNode };

en su lugar, hágalo opcional como se muestra a continuación:

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