ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Issue - CKEditor can't be used as JSX component

Open Srijit1998 opened this issue 1 year ago • 10 comments

📝 Provide detailed reproduction steps (if any)

  1. …Create a new React SPFx app
  2. …Install the dependency @ckeditor/ckeditor5-react: "6.1.0"
  3. …Import the CKEditor component from '@ckeditor/ckeditor5-react' (import { CKEditor } from '@ckeditor/ckeditor-react')

✔️ Expected result

The app should build properly without any errors.

❌ Actual result

I am getting errors as 'CKEditor cannot be used as a JSX component'.

image

📃 Other details

  • Browser: …Chrome
  • OS: …Windows
  • First affected CKEditor version: …'6.0.0'

package.json

{ "name": "ck-editor-app", "version": "0.0.1", "private": true, "engines": { "node": ">=16.13.0 <17.0.0" }, "main": "lib/index.js", "scripts": { "build": "gulp bundle", "clean": "gulp clean", "test": "gulp test" }, "dependencies": { "@ckeditor/ckeditor5-build-classic": "^41.0.0", "@ckeditor/ckeditor5-react": "^6.1.0", "@microsoft/sp-core-library": "1.17.1", "@microsoft/sp-lodash-subset": "1.17.1", "@microsoft/sp-office-ui-fabric-core": "1.17.1", "@microsoft/sp-property-pane": "1.17.1", "@microsoft/sp-webpart-base": "1.17.1", "office-ui-fabric-react": "^7.199.1", "react": "17.0.1", "react-dom": "17.0.1", "tslib": "2.3.1" }, "devDependencies": { "@microsoft/eslint-config-spfx": "1.17.1", "@microsoft/eslint-plugin-spfx": "1.17.1", "@microsoft/rush-stack-compiler-4.5": "0.4.0", "@microsoft/sp-build-web": "1.17.1", "@microsoft/sp-module-interfaces": "1.17.1", "@rushstack/eslint-config": "2.5.1", "@types/react": "17.0.45", "@types/react-dom": "17.0.17", "@types/webpack-env": "~1.15.2", "ajv": "^6.12.5", "eslint": "8.7.0", "eslint-plugin-react-hooks": "4.3.0", "gulp": "4.0.2", "typescript": "4.5.5" } }

Can anyone please help me on this?

@FilipTokarski @mdabkowska88

Srijit1998 avatar Jan 31 '24 14:01 Srijit1998

Facing same issue. Please help

tista-chatterjee avatar Jan 31 '24 14:01 tista-chatterjee

I have been facing the same issue. Completely blocked. Looking for resolution. Please help.

Priyaddutta avatar Jan 31 '24 15:01 Priyaddutta

@FilipTokarski @mdabkowska88

Tried to create and replicate this , facing the same. Wondering what could be the root cause. Please reach out if anyone has cracked through this

goodonestakenDJ avatar Jan 31 '24 18:01 goodonestakenDJ

Facing this issue for quite some time now. Any help and assistance would be appreciated. Thanks!

vag454arwal114 avatar Feb 01 '24 05:02 vag454arwal114

We appreciate all the comments, if you need access to immediate support, use our dedicated support channel. Meanwhile, please prepare for us a minimal reproducible sample that we could use (zip, stackblitz or a GitHub repo).

Witoso avatar Feb 01 '24 07:02 Witoso

Hi Witoso, thanks for the reply. I am providing the React SPFx app zip here. Please, let me know if you need anything else on this.

CKEditor_test.zip

@Witoso

Srijit1998 avatar Feb 01 '24 08:02 Srijit1998

Hi Witoso, did you find anything on this?

@Witoso

Srijit1998 avatar Feb 08 '24 14:02 Srijit1998

Experiencing the same problem, any updates?

Perneel avatar Mar 04 '24 09:03 Perneel

I am also facing the same issue, any solution for this?

divyavaniponugotu avatar Apr 25 '24 09:04 divyavaniponugotu

Still not fixed

Hard fix for ReactJS: const Editor: ({}:any) => JSX.Element = useMemo(() => CKEditor as unknown as () => JSX.Element, []);

Then use Editor as JSX element: <Editor editor={ ClassicEditor } />

guedesite avatar Aug 17 '24 23:08 guedesite

Consider adding allowSyntheticDefaultImports: true to your compilerOptions section of tsconfig.json. It may solve the issue.

Mati365 avatar Nov 08 '24 06:11 Mati365

I'm not sure but It seems like it requires React 19 types now. I had React 18 types and the error disappeared after I updated types to 19

murat-mehmet avatar Aug 07 '25 14:08 murat-mehmet