Skip to content

!== or shallow comparison in shouldComponentUpdate ? #10

Open
@happytuna75

Description

@happytuna75

JsonEditor.prototype.shouldComponentUpdate = function shouldComponentUpdate(_ref2) { var htmlElementProps = _ref2.htmlElementProps; return htmlElementProps !== this.props.htmlElementProps; };

In this function you compare with !== the new (yet to be applied) and the old (current) htmlElementProps.

In the docs you specify
* @property {object} [htmlElementProps] - html element custom props

but if htmlElementProps is an object than the comparison above will always return true, since you are comparing two distinct objects and for example, '{a: 1} !== {a: 1}' gives true.
Shouldn't you have a shallow comparison here? like suggested in https://reactjs.org/docs/shallow-compare.html and in particular
screen shot 2019-01-09 at 15 13 48

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions