Skip to content

Property 'getChildContext' does not exist on type 'Component<{}, {}, any>' (TypeScript) #217

@drwpow

Description

@drwpow

Using the functions from the theming section of the README in TypeScript, and getting the following error:

export const shallowWithTheme = (tree: React.ReactElement<{}>) => {
  const context = shallow(<ThemeProvider theme={theme} />)
    .instance()
    .getChildContext();
     ^^^^^^^^^^^^^^^
  return shallow(tree, { context });
};

error TS2339: Property 'getChildContext' does not exist on type 'Component<{}, {}, any>'.

This has something to do with enzyme’s instance() returning a generic React component that doesn’t seem to have a getChildContext method.

Has anyone else encountered this issue, and know of a workaround? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions