sealninja / react-grid-system

A powerful Bootstrap-like responsive grid system for React.
https://sealninja.github.io/react-grid-system/
MIT License
812 stars 83 forks source link

Refactor: Replace defaultProps with Default Function Parameters #506

Closed mateeusduarte closed 4 months ago

mateeusduarte commented 4 months ago

Overview

This PR addresses the upcoming deprecation of defaultProps in function components as signaled by React's warning: "Warning: ScreenClassProvider: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead." The changes involve updating the ScreenClassProvider, Col, Container, Row, Hidden, and Visible components within the react-grid-system library to use default function parameters for props instead of relying on defaultProps. This update ensures forward compatibility with future versions of React and adheres to modern JavaScript best practices.

Changes

Rationale

React is moving away from defaultProps in function components in favor of default function parameters, a more standard JavaScript approach. This change aligns react-grid-system with the latest React best practices and prepares it for future React versions. Furthermore, it simplifies the component code by leveraging default function parameters, which are more concise and easier to read.

Testing

The modifications were tested to ensure they don't alter the existing behavior of the react-grid-system. Components continue to function correctly with default props as expected, and the console warning about defaultProps deprecation is resolved.

I look forward to any feedback or suggestions for further improvement.

gerbenmeyer commented 4 months ago

Awesome stuff!