Skip to content

HOC - Can't access .root on unmounted test renderer #232

Description

@deepakaggarwal7

I've a logging HOC:

export const hasLogger = (prefix = '') => WrappedComponent => {
  const HasLogger = props => {
    console.log(`${prefix}[Props]:`, props)
    return <WrappedComponent {...props} />
  }

and a simple component

export const SomeComponent2 = props => <Text>{props.x + props.y}</Text>

While I am still thinking on the best way to validate it, but the test crashes at the render level itself:
with an error "Can't access .root on unmounted test renderer"

describe('HoC component', () => {
  it('logs  props with withlogging', () => {
    const { getByText } = render(hasLogger('')(<SomeComponent2 x={4} y={7} />))
  })
})

Any thoughts on a mistake I'm making or it's a library issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions