react-i18nify icon indicating copy to clipboard operation
react-i18nify copied to clipboard

Typescript error using the render method

Open euanmillar opened this issue 5 years ago • 1 comments

Hi,

I am migrating a js project that uses react-i18nify to Typescript. In many cases in the app I see the developer is using the render prop like this:

<I18n
        render={() => {

But the Typescript type does not expose this prop:

export class I18n extends React.Component {}

Therefore you get a "Property 'render' does not exist on type" error.

Many thanks.

euanmillar avatar Mar 19 '21 17:03 euanmillar

I'm not sure if this is right, but this seems to suppress the errror:

export interface I18nRender {
  render: () => JSX.Element
}

export class I18n<T extends I18nRender> extends React.Component<T, {}> { }

euanmillar avatar Mar 19 '21 17:03 euanmillar