Skip to content

迁移指南:react-feather → lucide-react

🌐 Migration Guide: react-feather → lucide-react

react-feather 类似于 lucide-react,该软件包的灵感来自于 react-feather。API 几乎相同,因此迁移非常简单。

1. 安装新软件包

🌐 1. Install the new package

sh
npm install lucide-react
npm uninstall react-feather

2. 更新导入

🌐 2. Update imports

将所有 react-feather 导入替换为 lucide-react

🌐 Replace all react-feather imports with lucide-react:

diff
- import { Home, User } from 'react-feather'
+ import { Home, User } from 'lucide-react'

你可以在整个代码库中使用查找和替换来完成此操作:

🌐 You can do this across your entire codebase with a find-and-replace:

  • 查找:from 'react-feather'
  • 替换:from 'lucide-react'

3. 重命名的图标

🌐 3. Renamed icons

四个图标已被重命名。请更新任何使用这些图标的地方:

🌐 Four icons have been renamed. Update any usages of these:

react-featherlucide-react
GitHubGithub
GridLayoutGrid
TableTable2
ToolWrench

示例

🌐 Examples

diff
- import { GitHub, Grid, Table, Tool } from 'react-feather'
+ import { Github, LayoutGrid, Table2, Wrench } from 'lucide-react'

- <GitHub />
+ <Github />

- <Grid />
+ <LayoutGrid />

- <Table />
+ <Table2 />

- <Tool />
+ <Wrench />

4. 所有其他图标

🌐 4. All other icons

所有剩余的图标保持相同的名称,并可作为直接替代使用。其他属性或用法无需更改。

🌐 All remaining icons keep the same name and work as drop-in replacements. No other changes to props or usage are required.