Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error two way binding #408

Open
lapillaga opened this issue Jan 16, 2025 · 4 comments
Open

Error two way binding #408

lapillaga opened this issue Jan 16, 2025 · 4 comments

Comments

@lapillaga
Copy link

Hey hello I have this error and I am not sure what's wrong
I created this component

import FroalaEditor from 'react-froala-wysiwyg';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';

interface EditorProps {
  value: string | object | null | undefined;
  onChange: (content: string) => void;
  config?: Record<string, any>;
}

const RichTextEditor = ({ value, onChange, config }: EditorProps) => {
  const defaultConfig = {
    placeholderText: 'Start typing...',
    ...config,
  };

  return (
    <FroalaEditor
      tag="textarea"
      model={value}
      onModelChange={onChange}
      config={defaultConfig}
    />
  );
};

export default RichTextEditor;

I called this component as following:

const DocumentInstanceView = ({
  currentVersion,
  showDeleteModal,
  setShowDeleteModal,
}: ViewDocumentPageProps) => {
  const [content, setContent] = useState<string>('');
  ........
  <div className={styles.document}>
    {currentVersion && (
      <RichTextEditor value={content} onChange={setContent} />
    )}
  </div>
}

I have this error

Image

The interesting point is if I remove this line it works: model={value}

Image
@shemetz
Copy link

shemetz commented Jan 20, 2025

We're having the same problem on my team -- this is blocking us from upgrading from Froala 4.3.1 to 4.4.0!

Setting the model to be undefined solved this error, but it's not a workable fix, because it prevents us from setting an initial value for the editor.

@ilyaskarim
Copy link

Hi @lapillaga,

To help us further troubleshoot the issue, Would you please recreate the issue in the following react sandbox demo and provide us with the steps to reproduce the error: https://codesandbox.io/p/sandbox/damp-dew-k6q589?file=%2Fsrc%2Findex.js%3A19%2C1?

@wmhafiz
Copy link

wmhafiz commented Jan 22, 2025

I ran into similar errors when trying to set initial value for the editor while also using onManualControllerReady for manual init

sandbox demo:
https://codesandbox.io/p/sandbox/quirky-gagarin-ctq26y?workspaceId=ws_AFJJsa7tuMFkyqWs4jmF9J

let me know if i miss out anything.

also, my actual repository is still using react 16.14.0
is it required to upgrade to react 18 in order to use v4.4.0 ?

@vedbhanushal1
Copy link

I am also facing similar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants