reactchel
reactchel

Reputation: 264

How to fix typescript error (Readonly<{}> & Readonly<{ children?: ReactNode; }>)?

How to fix typescript error?

I cloned the application from the working git repository, launched and received the error:

Property 'language' does not exist on type 'Readonly<{}> & Readonly<{ children?: ReactNode; }>'. TS2339

    <div className="login-block__form__head__text">
      {// @ts-ignore
      this.props.language === 'EN'// err
        ? 'Login'
        : 'LOGIN'}{' '}
    </div>

Unfortunately, I do not know the typescript, so I have to ask for help.

enter image description here

Upvotes: 0

Views: 431

Answers (1)

gnujoow
gnujoow

Reputation: 374

in this case, you didn't define props types.

interface PropType {
  language: string,
}

export default class ComponentName extends React.Component<PropType> {
...
}

if you want to learn more about typescript, the following links would be helpful.

Upvotes: 1

Related Questions