Fix 660 enable functions in props passed to recharts#661
Fix 660 enable functions in props passed to recharts#661AnnMarieW merged 4 commits intosnehilvj:masterfrom
Conversation
| data={data} | ||
| dataKey={dataKey} |
There was a problem hiding this comment.
Why did data and dataKey need to get added explicitly here (and in other components) rather than left in others? Won't they just pass through parseFuncProps unchanged?
There was a problem hiding this comment.
I don't understand why I have to do it this way, but data and dataKey are required props. Maybe it's the order that the type checking is done? Here is the error if I don't add them explicitly:
...is missing the following properties from type 'AreaChartProps': data, dataKey
ts-loader-default_e3b0c44298fc1c14
The parseFuncProps does spread all props. I verified that data and dataKey are in the others object. I couldn't eliminate the error unless I extracted those props.
Any suggestion on how to fix this?
There was a problem hiding this comment.
Ah ok - I guess TS can't figure out that parseFuncProps contains all the same keys in its output as input, but if you did try to tell it that you'd probably also have to tell it which ones changed type and how... so it'd turn into a mess. This way is easy and clean anyway, even if it's not immediately clear why it's needed, so we can leave it.
closes #660
Updated chart components to support additional functions as props
Modified
AreaChart,BarChart,BubbleChart,CompositeChart,LineChart, andScatterChartto accept functions for the following props:xAxisProps,yAxisProps,gridProps,rightYAxisProps(all charts)zAxisProps(BubbleChart only)Refactor:
resolveProp()calls withparseFuncProps()Note:
parseFuncProps()works only with optional props. Required props (likedataanddataKey) must be explicitly destructured and passed to the component to avoid TypeScript build errors.Example:
Sample App