react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

Some Tool bars are not working with the latest version of React

Open chidexebere opened this issue 2 years ago • 19 comments

Some of the tools are not working with the latest version of React (from React 18.0.0).

I have reproduced this on codesandbox here.

The dropdowns, images, emoji tools are among those not working.

I noticed this weird error on the console anytime I click on any of these tools. proxyConsole.js:64 Warning: Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to this.statedirectly or define astate = {}; class property with the desired state in the n component.

I have also tried using class components .....same issue.

chidexebere avatar May 27 '22 07:05 chidexebere

In my case, the buttons (Normal, Font, Size) don't show the dropdowns when they are clicked. Check this link, it can help. (https://stackoverflow.com/questions/72058578/dropdowns-are-not-working-using-react-draft-wysiwyg-in-react-js) It looks like it's not compatible with React 18. Here's a TinyMCE, I will try this. (https://www.youtube.com/watch?v=UTPsWbfHmFg)

AuboIoT avatar May 29 '22 22:05 AuboIoT

I have the same problem. Have you solved it?

Lin-403 avatar Jun 28 '22 07:06 Lin-403

@Lin-403 , the only workaround I found is using the old ReactDOM.render syntax instead of the new ReactDOMClient syntax.

That is, use this:

import ReactDOM from 'react-dom';

ReactDOM.render(
  <StrictMode>
      <App />
  </StrictMode>,
  document.getElementById('root'),
);

Instead of this:

import * as ReactDOMClient from "react-dom/client";

const rootElement = document.getElementById("root");
const root = ReactDOMClient.createRoot(rootElement);

root.render(
  <StrictMode>
    <App />
  </StrictMode>
);

chidexebere avatar Jul 03 '22 16:07 chidexebere

@chidexebere That is not a solution; by changing the code, you're switching back to react 17 and thus losing react 18 features ( that's the react-dom warning in the console)

houtan-rocky avatar Aug 25 '22 17:08 houtan-rocky

@jpuri Can you solve this problem with react 18?

houtan-rocky avatar Aug 25 '22 17:08 houtan-rocky

I switched to a rich text editor

https://www.wangeditor.com/

------------------ 原始邮件 ------------------ 发件人: "jpuri/react-draft-wysiwyg" @.>; 发送时间: 2022年8月26日(星期五) 凌晨1:28 @.>; @.@.>; 主题: Re: [jpuri/react-draft-wysiwyg] Some Tool bars are not working with the latest version of React (Issue #1270)

@jpuri Can you solve this problem with react 18?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Lin-403 avatar Aug 26 '22 04:08 Lin-403

So did I , Thank you for the wangeditor

clleker avatar Sep 28 '22 05:09 clleker

@jpuri Are you planning on solving the issue some day ? Is this repo dead ?

racso-dev avatar Nov 02 '22 09:11 racso-dev

I was able to solve this issue. The only problem is that RDW is not applying CSS for dropdowns. I copied the styles from dropdowns from an RDW demo, pasted them in my stylesheet, and manually applied them to the editor component.

`.rdw-dropdown-wrapper { height: 30px; background: white; cursor: pointer; border: 1px solid #f1f1f1; border-radius: 2px; margin: 0 3px; text-transform: capitalize; background: white; }

.rdw-dropdown-selectedtext { display: flex; position: relative; height: 100%; align-items: center; padding: 0 5px;

.rdw-dropdown-carettoclose {
  height: 0px;
  width: 0px;
  position: absolute;
  top: 35%;
  right: 10%;
  border-bottom: 6px solid black;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

.rdw-dropdown-carettoopen {
  height: 0px;
  width: 0px;
  position: absolute;
  top: 35%;
  right: 10%;
  border-top: 6px solid black;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
}

}

.rdw-dropdown-optionwrapper { z-index: 100; position: relative; border: 1px solid #f1f1f1; width: 98%; background: white; border-radius: 2px; margin: 0; padding: 0; max-height: 250px; overflow-y: scroll;

.rdw-dropdownoption-active {
  background: #f5f5f5;
}

.rdw-dropdownoption-default {
  min-height: 25px;
  display: flex;
  align-items: center;
  padding: 0 5px;
}

}`

MicahPowell avatar Nov 15 '22 14:11 MicahPowell

https://github.com/jpuri/react-draft-wysiwyg/issues/1291#issuecomment-1203348769

Found an answer that helps with this issue.

BossBele avatar Nov 30 '22 17:11 BossBele

The only solution to remove the React StrictMode....

instead of importing ReactDOM from 'react-dom' and reciving this waring: Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".

We can simply removed the React StrictMode...

const rootElement = document.getElementById("root"); const root = ReactDOMClient.createRoot(rootElement);

root.render( <App /> );

GodsonGodwin avatar Jan 07 '23 17:01 GodsonGodwin

The only solution to remove the React StrictMode....

instead of importing ReactDOM from 'react-dom' and reciving this waring: Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".

We can simply removed the React StrictMode...

const rootElement = document.getElementById("root"); const root = ReactDOMClient.createRoot(rootElement);

root.render( );

Rather than finding a solution, you're closing your eyes to the bugs.

houtan-rocky avatar Jan 07 '23 18:01 houtan-rocky

The only solution to remove the React StrictMode.... instead of importing ReactDOM from 'react-dom' and reciving this waring: Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client". We can simply removed the React StrictMode... const rootElement = document.getElementById("root"); const root = ReactDOMClient.createRoot(rootElement); root.render( );

Rather than finding a solution, you're closing your eyes to the bugs.

The issue has been opened since May, 2022 and the team is yet to responds to it. And the bug has persist with Reaact18 . Importing ReactDom from "react-dom" solve partially the issue but the bug still persist bcos how of React18 renders dom element... of course I know the consequences of turning off the React.StrictMode but that seems to be the only solution or the easy way out of the bug. Maybe you can help us fixed the bug and open up a pull request for that...

GodsonGodwin avatar Jan 08 '23 22:01 GodsonGodwin

The only solution to remove the React StrictMode.... instead of importing ReactDOM from 'react-dom' and reciving this waring: Warning: You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client". We can simply removed the React StrictMode... const rootElement = document.getElementById("root"); const root = ReactDOMClient.createRoot(rootElement); root.render( );

Rather than finding a solution, you're closing your eyes to the bugs.

The issue has been opened since May, 2022 and the team is yet to responds to it. And the bug has persist with Reaact18 . Importing ReactDom from "react-dom" solve partially the issue but the bug still persist bcos how of React18 renders dom element... of course I know the consequences of turning off the React.StrictMode but that seems to be the only solution or the easy way out of the bug. Maybe you can help us fixed the bug and open up a pull request for that...

I'll try.

houtan-rocky avatar Jan 09 '23 14:01 houtan-rocky

I copied the styles from dropdowns from an RDW demo, pasted them in my stylesheet, and manually applied them to the editor component.

@MicahPowell Would you give a small hint how you applied pasted styles to the editor component? Cheers!

mat-jar avatar Jan 11 '23 02:01 mat-jar

if you are using next js change reactStrictMode: false in next.config.js

ShaikhMohammaddanish avatar Aug 25 '23 07:08 ShaikhMohammaddanish

remove StrictMode in react

<React.StrictMode> <App /> </React.StrictMode>,

ShaikhMohammaddanish avatar Aug 25 '23 07:08 ShaikhMohammaddanish

Same situation here. Issue has been resolved after I commented 'React.StrictMode'.

mustom avatar Nov 08 '23 13:11 mustom