问题标签 [react-icons]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1488 浏览

reactjs - 从 JSON 文件中动态显示 reactjs 图标图标名称

我有以下 json 文件,我保留了 Id、Intro、Icon 名称

我在可重复使用的卡片组件中使用React-Bootstrap-Icons,如下所示

这就是我循环 json 文件和显示卡片的方式

但我想把它带到下一个层次,即动态显示图标,从 json 文件中获取,目前它是静态的。

所以我只是试着这样说

但它首先显示编译错误。我可以知道是否有任何方法可以实现这一目标

0 投票
2 回答
1557 浏览

reactjs - 如何根据数据库中的字符串呈现反应图标?

我正在尝试创建多个包含信息的框,每个框都有一个图标。现在我已经硬编码如下:

现在,为了能够动态添加更多这些组件,我想实现一个数据库。大多数情况下这很容易,我只是不知道如何使用 react-icons 组件来实现它?我应该使用其他东西还是有可能?

0 投票
2 回答
81 浏览

reactjs - 如何通过单击图标警报(“确定”)来响应本机按钮

如何通过单击图标警报(“确定”)来响应本机按钮,我想放置点三垂直谢谢...

看这里的图片 点三垂直图标示例

0 投票
4 回答
309 浏览

javascript - 在 React 中使用变量渲染组件

react-icons在“卡片组件”中有一个通过道具的列表。在我的 Card 组件的渲染方法中,我有这样的东西:

注意:该列表由 react-icons 组成,它们本身就是 React 组件。

我尝试了很多东西,但我不太清楚如何渲染图标。如果有人可以帮助我,那就太棒了。谢谢

0 投票
2 回答
1068 浏览

css - 在 ReactJS 中单击时如何更改心形(愿望清单图标)颜色?

如何在单击时更改图标的颜色并且单击后颜色保持不变。它不会改变他们的状态。

详细信息.scss

0 投票
1 回答
198 浏览

reactjs - 为什么安装 babel-loader 后 yarn 会报错?

安装react-icons包后,我的代码抛出了一个错误,说我的babel-loader包丢失了,所以我也安装了那个包。

接下来我知道,我跑了yarn start,出现了这个错误:

我尝试使用npm start,应用程序启动得很好。

怎么了?

0 投票
1 回答
620 浏览

styled-components - 使用样式化组件如何将主题颜色从全局样式传递给 React Icons Context Provider?

寻找一种将颜色从主题传递到 React 图标的方法。主题工作正常,我可以将颜色传递给我的样式组件。这是细分:

index.js:

app.js(精简):

相当于:

确实有效,我确实尝试过:

导航元素.js:

应用程序.js:

但我得到一个儿童错误。尝试来自阅读 Q&A Styled-components 和 react-icons <IconContext.Provider> 组件

我没有找到的其他问答:

使用 Styled Components 中的主题颜色,我如何将该颜色传递给 React Icons Provider?

0 投票
2 回答
1020 浏览

css - 如何更改 React 图标的填充颜色?

我想改变 React-icons 的颜色。比如说,{AiFillHeart}图标。我想将其填充颜色更改为红色。我怎样才能做到这一点?

我试过了<AiFillHeart style = {{color: 'red'}}/>。但它不起作用。

0 投票
1 回答
230 浏览

webpack - Use react-icons for pointStyles in Chart.js graph on Next.js app

Problem:
I'm trying to use the react-icons MdNavigation icon as a pointStyle within Chart.js. The app is built in Next.js. If it's not possible to use react-icons for a chart.js pointStyle, I'm open to using an imported SVG, jpg or png icon, but even still I'm having issues likely caused by my setup of the file-loader in next.config.js.

Expected result:
I expect for the MdNavigation icon (https://react-icons.github.io/react-icons/icons?name=md) to show up for the pointStyles.

Actual result:
I have tried a few different setups to get this to work, but so far none of them have given me to correct icon.
I've gotten the following error with a few different configurations:

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.

Config #1 to return the above error:

I get the same error when I do the following setup:

I've also tried the following setup in an attempt to create a wrapper for the MdNavigation icon:

Ideally, I'd like to use that icon as the pointStyle. If that isn't possible, I'm open to using another jpg or png image, but I'm still having issues with that. The following code is my setup when I try to use a different image (likely caused by my file-loader setup. I'm not great with these config files yet). This setup also give me the following error:

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.

Loader config (next.config.js):

Also tried setting this up in webpack.config.js:

0 投票
1 回答
599 浏览

javascript - React - How to specify an icon in an object as a value

I have an array with objects before, I applied icons from fontAwesome as a value, it looked like this

Then in another component I got this icon like this

Now I use a different approach (React Icons), the point is that now I create icons in this way

In this case, I cannot assign this icon inside the object as a value, it gives an error

What should I do in this case?