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

Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead #159

Open
jeadys opened this issue Oct 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@jeadys
Copy link

jeadys commented Oct 20, 2023

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Other... Please describe:

defaultProps currently deprecated and will be removed in React 18.3.0

Current behavior

// Example from LineChart.tsx

import React, { FC } from 'react';
import { AreaChart, AreaChartProps } from '../AreaChart';
import { LineSeries } from './LineSeries';

export type LineChartProps = AreaChartProps;

export const LineChart: FC<Partial<LineChartProps>> = (props) => (
  <AreaChart {...props} />
);

LineChart.defaultProps = {
  ...AreaChart.defaultProps,
  series: <LineSeries />
};

Expected behavior

// Example from LineChart.tsx

import React, { FC } from 'react';
import { AreaChart, AreaChartProps } from '../AreaChart';
import { LineSeries } from './LineSeries';

export type LineChartProps = AreaChartProps;

export const LineChart: FC<Partial<LineChartProps>> = ({
  series = <LineSeries />,
  ...props
}) => <AreaChart {...props} />;

What is the motivation / use case for changing the behavior?

defaultProps currently deprecated and will be removed in React 18.3.0

Environment


Libs:
- react version: 18.2.0
- reaviz version: 14.14.4
@amcdnl amcdnl added the bug Something isn't working label Oct 20, 2023
@amcdnl amcdnl self-assigned this Oct 20, 2023
@amcdnl
Copy link
Member

amcdnl commented Oct 20, 2023

Unfortuantly the way the APIs are used it needs to be initialized via default props. We are going to need to re-evaluate our strategy for this in the upcoming release. Thanks for highlighting, if you are interested in contributing let me know.

@jeadys
Copy link
Author

jeadys commented Oct 22, 2023

yea, would like to contribute where needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants