import React from 'react'; import { NavContext } from '../contexts/NavContext'; import type { IonicReactProps } from './IonicReactProps'; import { IonIconInner } from './inner-proxies'; import { createForwardRef, isPlatform } from './utils'; interface IonIconProps { color?: string; flipRtl?: boolean; icon?: string; ios?: string; lazy?: boolean; md?: string; mode?: 'ios' | 'md'; name?: string; size?: string; src?: string; } type InternalProps = IonIconProps & { forwardedRef?: React.ForwardedRef; }; class IonIconContainer extends React.PureComponent { constructor(props: InternalProps) { super(props); if (this.props.name) { console.warn( 'In Ionic React, you import icons from "ionicons/icons" and set the icon you imported to the "icon" property. Setting the "name" property has no effect.' ); } } render() { const { icon, ios, md, ...rest } = this.props; let iconToUse: typeof icon; if (ios || md) { if (isPlatform('ios')) { iconToUse = ios ?? md ?? icon; } else { iconToUse = md ?? ios ?? icon; } } else { iconToUse = icon; } return ( {this.props.children} ); } static get contextType() { return NavContext; } } export const IonIcon = createForwardRef( IonIconContainer, 'IonIcon' );