File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ export type MemoElement = {
103103export type ForwardRefElement = {
104104 type : {
105105 render : ComponentType < DefaultProps > & ComponentStatics ,
106- $$typeof : typeof REACT_FORWARD_REF_TYPE
106+ $$typeof : typeof REACT_FORWARD_REF_TYPE ,
107+ styledComponentId ?: string // styled-components specific property
107108 } ,
108109 props : DefaultProps ,
109110 $$typeof : typeof REACT_ELEMENT_TYPE
Original file line number Diff line number Diff line change @@ -128,11 +128,18 @@ export const visitElement = (
128128
129129 case REACT_FORWARD_REF_TYPE: {
130130 const refElement = ( ( element : any ) : ForwardRefElement )
131- // Treat inner type as the component instead of React.forwardRef itself
132- const type = refElement . type . render
133- const props = refElement . props
134- const child = mountFunctionComponent ( type , props , queue , visitor )
135- return getChildrenArray ( child )
131+ if ( typeof refElement . type . styledComponentId === 'string' ) {
132+ // This is an optimization that's specific to styled-components
133+ // We can safely skip them and return their children
134+ return getChildrenArray ( refElement . props . children )
135+ } else {
136+ const {
137+ props,
138+ type : { render }
139+ } = refElement
140+ const child = mountFunctionComponent ( render , props , queue , visitor )
141+ return getChildrenArray ( child )
142+ }
136143 }
137144
138145 case REACT_ELEMENT_TYPE: {
You can’t perform that action at this time.
0 commit comments