Skip to content

Throws TypeError when trying to logWarnings on undefined host #102

@mrfr0g

Description

@mrfr0g

I have a sortable component which defers to jQuery's UI sortable plugin. The plugin attaches itself to the DOM during the componentDidMount event. When an item is ordered I cancel the event (which restores the DOM order) and update the internal state of the component to match the new children render order. Its a similar solution to, http://stackoverflow.com/questions/29725136/jquery-ui-sortable-with-react-js-buggy.

When the setState method is called react-a11y attempts to hook into the rendered components and log warnings about the component, and ultimately fails because (I believe) the component is being reordered by React at the time. Effectively its failing at this step;

lib/index.js

121: if (includeSrcNode && component)
122:   // Cannot log a node reference until the component is in the DOM,
123:   // so defer the document.getElementById call until componentDidMount
124:   // or componentDidUpdate.
125:   logAfterRender(component._instance, warn);

component._instance is undefined in this case, so during the logAfterRender step its trying to access properties of an undefined object and throwing a TypeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions