Skip to content

Commit e9b61ee

Browse files
authored
Fix memo component nested in forwardRef HOC (#40)
This is the same fix as #15, but for the opposite way around.
1 parent bcbe951 commit e9b61ee

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/__tests__/visitor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ describe('visitElement', () => {
201201
})
202202

203203
it('walks over forwardRef components', () => {
204-
const Test = React.forwardRef(() => <Noop />)
204+
const Test = React.forwardRef(Noop)
205205
const children = visitElement(<Test />, [], () => {})
206206
expect(children.length).toBe(1)
207207
expect(children[0].type).toBe(Noop)

src/visitor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const visitElement = (
136136

137137
case REACT_MEMO_TYPE: {
138138
const memoElement = ((element: any): MemoElement)
139-
const type = memoElement.type.type
139+
const { type } = memoElement.type
140140
const child = createElement((type: any), memoElement.props)
141141
return getChildrenArray(child)
142142
}
@@ -152,8 +152,7 @@ export const visitElement = (
152152

153153
const { render: type, defaultProps } = refElement.type
154154
const props = computeProps(refElement.props, defaultProps)
155-
const fauxElement = (createElement((render: any), props): any)
156-
const child = render(type, props, queue, visitor, fauxElement)
155+
const child = createElement((type: any), props)
157156
return getChildrenArray(child)
158157
}
159158

0 commit comments

Comments
 (0)