ResponsiveBar prop types don't align with documentation
See original GitHub issueDescribe/explain the bug
When applying the label
prop to ResponsiveBar Nivo will only allow functions that return strings, rather than functions that return SVG Elements.
To Reproduce
Steps to reproduce the behavior:
- Create a function that accepts BarDatum and returns an SVG element
- Pass it to
<ResponsiveBar />
Expected behavior
TypeScript allows me to pass a function that returns an SVGAElement without me having to cast the return type with as unknown as string
.
TypeScript TS 4.3.5
Additional context
This issue seems to stem from the fact that BarSvgProps
extends BarCommonProps
, which uses the Nivo core PropertyAccessor
. The second type parameter is string
, which is true for Canvas charts, but for SVG charts, it should also allow SVGAElement
(PropertyAccessor<Datum, string | SVGAElement>
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Validating Props easily with React PropTypes - codeburst
React PropTypes are a good way to help you catching bugs by validating data types of values passed through props.
Read more >At least one required prop in React - Stack Overflow
I wrote this helper to solve the same problem in a re-usable way. You use it like a propType function: MyComponent. propTypes =...
Read more >Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >'data' is missing in props validation - You.com | The AI Search ...
I am getting this error: 'data' is missing in props validation eslint(react/prop-types). What am I missing? eslint (react/prop-type) was referenced, ...
Read more >I'm Breaking up with Higher Order Components. | - Medium
import PropTypes from 'prop-types';class Caffeinate extends Component { ... We don't have to worry about prop name conflicts with other ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@plouc - Can you clarify how those solutions would look? I don’t see a way to do this without type casting even with your hints…
On a different note, I’m also confused why blocking this would be a preferable route over making the actual API surface align with the documented one
Can someone tell me How to keep label values above bars in bargraph?