codedthemes / berry-free-react-admin-template

Berry free react material-ui admin template for easing and faster web development.
https://berrydashboard.io/free/
MIT License
1.77k stars 880 forks source link

Optimization: Remove repetitive use of darkTitle prop and instead use ternary conditional to render appropriate title #51

Closed shahx95 closed 1 year ago

shahx95 commented 1 year ago

In the MainCard.js component linked here, the darkTitle prop is used to determine whether to use a Typography component with the variant of "h3" or not. The code checks the value of the darkTitle prop and, if it is true, it renders a Typography component with the variant of "h3", otherwise, it renders the title prop as is.

Instead of having repeated checks for darkTitle, we can use a ternary operator to check the value of darkTitle and conditionally render the title prop with or without the Typography component. This makes the code simpler and more readable.

Current code: image

After optimizing: image

shahx95 commented 1 year ago

Pull request for the suggested optimization: https://github.com/codedthemes/berry-free-react-admin-template/pull/52