The React Exclusive Auto Importer is a Visual Studio Code (VSCode) extension designed to automate the import of React components in TypeScriptReact files. It analyzes your TypeScriptReact code and automatically adds import statements for the components you are using in your JSX.
-
Automatic Import: The extension automatically identifies React components used in your TypeScriptReact files and adds import statements for them.
-
Configuration: You can configure named imports and default imports for specific components through the extension settings.
- Open VSCode.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or use the keyboard shortcut
Ctrl+Shift+X
. - Search for "React Exclusive Auto Importer" in the Extensions view search box.
- Click on the "Install" button to install the extension.
- Ensure the extension is installed and activated.
- Open a TypeScriptReact file.
- As you write JSX code, the extension will automatically detect the components you use.
- If a component is not already imported, the extension will add the appropriate import statement at the beginning of the file.
You can configure the extension by modifying your VSCode settings. Add the following configuration options to your settings.json
file:
"react-exclusive-auto-importer": {
"namedImports": {
"ComponentName": "path/to/component-file",
// Add other named imports as needed
},
"defaultImports": {
"ComponentName": "path/to/component-file",
// Add other default imports as needed
}
}
namedImports
: Specify named imports for specific components.defaultImports
: Specify default imports for specific components.
// Before
const App = () => {
return <MyComponent />;
};
// After
import { MyComponent } from "path/to/component-file";
const App = () => {
return <MyComponent />;
};
"react-exclusive-auto-importer": {
"namedImports": {
"CustomComponent": "components/CustomComponent",
"AnotherComponent": "components/AnotherComponent"
}
}
// Before
const App = () => {
return <CustomComponent />;
};
// After
import { CustomComponent } from "components/CustomComponent";
const App = () => {
return <CustomComponent />;
};
This extension is licensed under the MIT License.
If you encounter any issues or would like to contribute to the development of this extension, please visit the GitHub repository.