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

[Frontend] Fix BarChart and MetricsCategoryBarCharts new lint errors in common repo #803

Open
mxosman opened this issue Jul 31, 2023 · 2 comments

Comments

@mxosman
Copy link
Contributor

mxosman commented Jul 31, 2023

BarChart.tsx

  158:21  error  Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component and pass data as props. If you want to allow component creation in props, set allowAsProps option to true  react/no-unstable-nested-components

MetricsCategoryBarChart.tsx

  126:23  error  Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component and pass data as props. If you want to allow component creation in props, set allowAsProps option to true  react/no-unstable-nested-components

The errors are referring specifically to us defining an anonymous function within the tick prop. We can define this before the render and pass in the function reference to the tick prop.

              <YAxis
                tick={(props: TickProps) => (
                  <CustomYAxisTick
                    y={props.y}
                    payload={props.payload}
                    percentageView={false}
                    styles={tickStyle}
                  />
                )}
                ...
@mxosman mxosman changed the title [Frontend] Fix BarChart and MetricsCategoryBarCharts new lint errors [Frontend] Fix BarChart and MetricsCategoryBarCharts new lint errors in common repo Jul 31, 2023
@lilidworkin
Copy link
Collaborator

@mxosman would this be a good task for Ilya or should we just close it?

@mxosman
Copy link
Contributor Author

mxosman commented Apr 1, 2024

I think so! Should be a simple one I hope!

@lilidworkin lilidworkin assigned nasaownsky and unassigned mxosman and nasaownsky Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants