reactjs - Render component when receive props ans styled it inline -


i try render component when parent receives props. catch error:

element type invalid: expected string (for built-in components) or class/function (for composite components) got: object. use material ui, when icon props true need render element inside floatingactionbutton. in case use <icon /> catch error, in case use icon - wroks, how apply styles.

const iconbutton = ({color = 'normal', icon, ...props}) =>{     let icon = icon     console.log(icon)     return <floatingactionbutton         disabletouchripple         mini         zdepth={1}         {...props}         {...getstyle(color, props.disabled, props.icon)}         >         {!!icon && <icon />}         </floatingactionbutton> }  <iconbutton color='hightligted' icon={<add />} /> 

this variant works, how set style in case icon :

{!!icon && icon} 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -