react-native-svg-charts icon indicating copy to clipboard operation
react-native-svg-charts copied to clipboard

Tooltip and Decorator throws Typescript error

Open garrettg123 opened this issue 4 years ago • 4 comments

What is the problem?

Rendering <Tooltip /> inside <StackedBarChart /> throws

Type '{}' is missing the following properties from type '{ width: any; height: any; }': width, heightts(2739)

and similarly with <Decorator />

'Decorator' cannot be used as a JSX component.
  Its return type 'unknown[]' is not a valid JSX element.
    Type 'unknown[]' is missing the following properties from type 'Element': type, props, keyts(2786)

When does it happen?

with the definitions

const Tooltip = ({ width, height }) => {
// ...
const Decorator = ({ x, y, data }) => {

What platform?

  • [X] iOS
  • [ ] Android

react-native version: 0.61.4 react-native-svg-charts version: ^5.3.0 react-native-svg version: 11.0.1

Code to reproduce

// put code here

garrettg123 avatar Jun 24 '20 02:06 garrettg123

Hi @garrett-gottlieb ! I was facing the same issue, you just need to provide 'any' type to your components props. I think TS isn't already supported by childrens, but I may be wrong. Anyway, providing 'any' type to props seems to solve this issue.

ajacquierbret avatar Jul 02 '20 07:07 ajacquierbret

@ajacquierbret can you leave a code comment - I've tried but not sure what you mean exactly to clear up this typescript error

Trashpants avatar Aug 24 '20 20:08 Trashpants

Hi @garrett-gottlieb ! I was facing the same issue, you just need to provide 'any' type to your components props. I think TS isn't already supported by childrens, but I may be wrong. Anyway, providing 'any' type to props seems to solve this issue.

Negative, not working.

sr1jan avatar Oct 02 '20 13:10 sr1jan

What is the problem?

Rendering <Tooltip /> inside <StackedBarChart /> throws

Type '{}' is missing the following properties from type '{ width: any; height: any; }': width, heightts(2739)

and similarly with <Decorator />

'Decorator' cannot be used as a JSX component.
  Its return type 'unknown[]' is not a valid JSX element.
    Type 'unknown[]' is missing the following properties from type 'Element': type, props, keyts(2786)

When does it happen?

with the definitions

const Tooltip = ({ width, height }) => {
// ...
const Decorator = ({ x, y, data }) => {

What platform?

  • [x] iOS
  • [ ] Android

react-native version: 0.61.4 react-native-svg-charts version: ^5.3.0 react-native-svg version: 11.0.1

Code to reproduce

// put code here

Did you fix this?

sr1jan avatar Oct 02 '20 13:10 sr1jan