ionic-framework: bug: ionicons aren't loaded in react
Bug Report
Ionic version: [x] 4.x
Current behavior:
Using the <IonIcon /> component will always try to retrieve the svg from the wrong location. As far as I can tell, this is an issue with the new @ionic/react release.
Looking in the network tab on chrome, I see two different locations for individual svgs.
md-menu (used internally by ionic): http://localhost:3000/static/media/md-menu.4e10f85b.svg
md-happy: http://localhost:3000/svg/md-happy.svg
Since /svg isn’t bundled by CRA, it’ll always return the root object.
Expected behavior:
<IonIcon /> should pull the svg from the CORRECT location
Steps to reproduce:
- Create a new project using create-react-app
- Create 2 IonIcon components, one loaded by ionic and one random.
- View project by either using
npm startornpm run build. - Open the network tab to view sources
class Page extends React.Component {
render() {
<IonIcon name='menu' />
<IonIcon name='happy' />
}
}
ReactDOM.render(<Page />, document.getElementById('root'))
Ionic info:
Ionic:
Ionic CLI : 5.2.3 (/usr/local/lib/node_modules/ionic)
Capacitor:
Capacitor CLI : 1.1.1
@capacitor/core : 1.1.1
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v10.14.2 (/usr/local/bin/node)
npm : 6.10.1
OS : macOS Mojave
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 31 (10 by maintainers)
The only workaround i’ve been able to find:
@obedm503 Yep, tree shaking and only downloading the icon svgs that you actually use.
However, it doesn’t work with “IonBackButton” (when trying to change the default icon). Is there a way to handle that too?
Thanks in advance 😃