react-html5-camera-photo icon indicating copy to clipboard operation
react-html5-camera-photo copied to clipboard

Support for defaultProps will be removed from function components in a future major release

Open heyajohnny opened this issue 9 months ago • 2 comments

Running on react 18.3.1 I get these errors:

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

According to AI, this should be the fix: Here’s an example of how you can transition from defaultProps to default parameters in a functional component:

// Before: using defaultProps
function Greeting({ name }) {
  return <div>Hello, {name}!</div>;
}

Greeting.defaultProps = {
  name: 'World',
};

// After: using default parameters
function Greeting({ name = 'World' }) {
  return <div>Hello, {name}!</div>;
}

Using default parameters simplifies the component and aligns with modern JavaScript practices. It’s a good idea to start refactoring your components to use default parameters if you haven’t already, to prepare for the upcoming changes in React.

heyajohnny avatar May 17 '24 07:05 heyajohnny