Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options not working in typescript #84

Open
el-sacapuntas opened this issue Jun 6, 2021 · 2 comments
Open

Options not working in typescript #84

el-sacapuntas opened this issue Jun 6, 2021 · 2 comments

Comments

@el-sacapuntas
Copy link

 const options = {
        colors: ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b"],
        enableTooltip: true,
        deterministic: false,
        fontFamily: "impact",
        fontSizes: [5, 60],
        fontStyle: "normal",
        fontWeight: "normal",
        padding: 1,
        rotations: 3,
        rotationAngles: [0, 0],
        scale: "sqrt",
        spiral: "rectangular",
        transitionDuration: 1000
      };
    
    return (
        <Box>
        <ReactWordcloud
            words={words}
            options = {options}  // <- ERROR HERE
        />
        </Box>
    )

error:

Type '{ colors: string[]; enableTooltip: boolean; deterministic: boolean; fontFamily: string; fontSizes: number[]; fontStyle: string; fontWeight: string; padding: number; rotations: number; rotationAngles: number[]; scale: string; spiral: string; transitionDuration: number; }' is not assignable to type 'Optional<Options>'.
  Types of property 'fontSizes' are incompatible.
    Type 'number[]' is not assignable to type 'MinMaxPair'.
      Target requires 2 element(s) but source may have fewer.
The expected type comes from property 'options' which is declared here on type 'IntrinsicAttributes & Props'
@satya0306
Copy link

you need to define options type.
you can write
const options:any = {
......
};

@mindong2
Copy link

no,
import { OptionsProp } from 'react-wordcloud';

const options: OptionsProp= {
....
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants