Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get component inside react-emotion or styled-component

import styled from 'react-emotion'

class Field extends React.Component<> {}

export default styled(Field)

then if I render this component and use component.type, i get styled()... function instead of Field component.

How I get Field inside styled function?

like image 322
AHOYAHOY Avatar asked Nov 18 '22 22:11

AHOYAHOY


1 Answers

Try this:

import styled from 'react-emotion'

const Field = ({ className }) => (
    <div className={className}>Some field</div>
)

const theField = styled(Field)`
    color: green;
`
export default theField 
like image 60
mike123 Avatar answered Dec 14 '22 23:12

mike123