feat: add multiple-share-scope example#4419
Conversation
| @@ -0,0 +1,14 @@ | |||
| import { Helmet } from '@modern-js/runtime/head'; | |||
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
In general, unused imports should be removed to keep the code clean and avoid confusion. Since Helmet is not used anywhere in page.tsx, the best fix that does not alter existing runtime behavior is simply to delete the unused import line.
Specifically, in multiple-share-scope/provider-react-17/src/routes/page.tsx, remove line 1 (import { Helmet } from '@modern-js/runtime/head';). No additional methods, imports, or definitions are needed, and no other lines require adjustment.
| @@ -1,4 +1,3 @@ | ||
| import { Helmet } from '@modern-js/runtime/head'; | ||
| import './index.css'; | ||
| // import Provider from 'provider'; | ||
|
|
| import React, { useState } from 'react'; | ||
|
|
||
| const LandingPage = (props: any): JSX.Element => { | ||
| const [count, setCount] = useState(0); |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
In general, to fix an unused variable from a React useState call, either remove the unused binding or replace it with a placeholder (like _) so only the actually used parts are declared. This preserves functionality while eliminating the unused variable.
Here, the component only reads count and never calls setCount. The best fix is to destructure only the first element of the state tuple and ignore the setter. In TypeScript/React, we can do this by omitting the second element in the array destructuring. Concretely, in multiple-share-scope/provider-react-18/src/components/LandingPage.tsx, line 5 should be changed from const [count, setCount] = useState(0); to const [count] = useState(0);. No other lines or imports need to change, and no new methods or definitions are required.
| @@ -2,7 +2,7 @@ | ||
| import React, { useState } from 'react'; | ||
|
|
||
| const LandingPage = (props: any): JSX.Element => { | ||
| const [count, setCount] = useState(0); | ||
| const [count] = useState(0); | ||
| console.log(props); | ||
| return <div className={styles.libRow}>landing-page react 18 {count} </div>; | ||
| }; |
No description provided.