Skip to content

Changed lines rendered blank in v4 with custom renderContent #67

Open
@denis-sokolov

Description

@denis-sokolov

In 4.0.5, if DiffViewer has a custom renderContent, the component sometimes silently renders a blank line.

Turns out, word compareMethod is not compatible with renderContent, if renderContent returns anything but a string. Ironically, the type of it allows to return only non-strings:

// Render prop to format final string before displaying them in the UI.
renderContent?: (source: string) => ReactElement;

Reproduce:

<DiffViewer
  compareMethod={DiffMethod.WORDS}
  newValue="Foo Bar"
  oldValue="Foo"
  renderContent={str => <div>{str}</div>}
  />

The cause seems to be this silent return statement, introduced in c0c99f5:

if (typeof content !== "string") return;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions