Giter Site home page Giter Site logo

Comments (7)

ckifer avatar ckifer commented on June 11, 2024 1

Might be related to #4382

As mentioned in the other issues, these types aren't in the best state right now.

This seems applicable: https://stackoverflow.com/a/65533906/8050147

This is probably an artifact of recharts still being on react v16 types, where you are on react 18 types.
React types will be upgraded in v3, but for now I'm not quite sure what you would do. See the other issue for what we did there, but I'm not sure that this is the same exact problem yet.

Just FYI LegendProps is to Legend and DefaultLegendContentProps is to DefaultLegendContent, so when you're using content DefaultLegendContent should be what is returned (rather than Legend)

And LegendProps should be used when spreading onto Legend

from recharts.

ckifer avatar ckifer commented on June 11, 2024 1

Legend is the Legend component, its what is documented and expected to be used for a legend.

content in Legend is for rendering custom Legend content using what Legend calculates internally as input

DefaultLegendContent is what is returned normally, by default, by recharts. So

content={props => <DefaultLegendContent {...props} />} should result in the same result as not specifying content at all. Its mostly useful if you want to transform the data that DefaultLegendContent receives, but not really the display (or maybe you want to wrap the default content, etc.).

The names of the types are confusing, apologies for that. This has been around for a while

from recharts.

ckifer avatar ckifer commented on June 11, 2024

Can you give a code example of where exactly you're trying to use the type (the usage matters)?

from recharts.

isabelleli avatar isabelleli commented on June 11, 2024

@ckifer Thanks for responding so quickly! Here's a sandbox demonstrating the error.

from recharts.

ckifer avatar ckifer commented on June 11, 2024
  config: {
    legendProps?: Omit<LegendProps, "ref">;
    lines: Array<{
      key: string;
      legendValue: string;
    }>;
  };

This fixes your issue for now (you shouldn't need the ref)

from recharts.

isabelleli avatar isabelleli commented on June 11, 2024

@ckifer Ah gotcha, thanks for the suggested fix! Just out of curiosity, what is the difference and the intended use-cases between DefaultLegendContent and Legend?

from recharts.

isabelleli avatar isabelleli commented on June 11, 2024

Gotcha, thank you for explaining! I'll go ahead and close out this issue.

from recharts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.