Aeolun / react-diff-viewer-continued

A simple and beautiful text diff viewer component made with Diff and React.
https://aeolun.github.io/react-diff-viewer-continued/
MIT License
113 stars 34 forks source link

Error using ReactDiffView in Remix App #43

Open guepjo opened 4 months ago

guepjo commented 4 months ago

Summary

I am running into an error when trying to use this library

import ReactDiffViewer from "react-diff-viewer-continued";

export const DiffExpandView = () => {
    return (
        <>
            <ReactDiffViewer
                oldValue={"sourceVersion"}
                newValue={"newVersion"}
                splitView={true}
                // linesOffset={5}
            />
        </>
    );
}

Here is the error I get:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Context

I am working with a remix-react app.

Any idea how to fix this? This component would really fit my current needs so I would love to be able to use it

ObaidAshiq commented 4 months ago

i think your data might be an object, supposedly either sourceVersion or newVersion, Which should have been string , mind checking these values or sharing them ?

guepjo commented 4 months ago

@ObaidAshiq I have updated it to remove the curly braces, but it still doesn't work

import ReactDiffViewer from "react-diff-viewer-continued";

export const DiffExpandView = () => {
    return (
        <>
            <ReactDiffViewer
                oldValue="source Version" <-- removed curly braces
                newValue="new Version"  <-- removed curly braces
                splitView={true}
                // linesOffset={5}
            />
        </>
    );
}
Aeolun commented 4 months ago

I assume it has something to do with SSR somehow, but not quite sure what that would be. I'll have to boot it in a Remix app to see what effect it has.

davidalejandroaguilar commented 1 month ago

This also happens with a basic InertiaJS + Vite using SSR https://inertia-rails.netlify.app/guide/. The component fails during SSR, and then renders correctly on the client.

Pretty tired at the moment to create a basic reproduction app, but hoping to do one soon.