mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.3k stars 32.12k forks source link

[system] initColorSchemeScript.tsx uses var instead of let #43418

Closed oliviertassinari closed 2 weeks ago

oliviertassinari commented 2 weeks ago

Summary

We use var:

https://github.com/mui/material-ui/blob/9f4b846be96ee18733b6bd77eba2f54b1ceb9b04/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.tsx#L95

but this seems confusing. Why not let? For example, https://github.com/pacocoursey/next-themes/blob/bf0c5a45eaf6fb2b336a6b93840e4ec572bc08c8/next-themes/src/script.ts#L14 who use modern syntax.

Using let over var seems to have two benefits:

Motivation

I was confused by this looking into #43416.

ilyastorunn commented 2 weeks ago

Hi, would you like to create a PR?

ishon19 commented 2 weeks ago

Hi, would you like to create a PR?

Hey @ilyastorunn! I can do that, but go ahead if you have one ready.

m-sathish-varma commented 2 weeks ago

Hi @oliviertassinari, var might have been used because the code was written in an environment where ES6 (let and const) was not supported, or it’s older code.

Michael-Hutchinson commented 2 weeks ago

I can pick this up if you like?