thanhtunguet / grapesjs-react

A React wrapper for GrapesJS library
https://thanhtunguet.github.io/grapesjs-react
194 stars 58 forks source link

Can't import it on React and Nextjs #53

Closed anuragk15 closed 3 years ago

anuragk15 commented 3 years ago

I tried importing this library on Nextjs first and failed(despite dynamic loading etc). Thought its a problem with Nextjs config or something and therefore moved to React. Same problem on React too.

import 'grapesjs-preset-webpage';
import {Editor} from 'grapesjs-react'

import 'grapesjs/dist/css/grapes.min.css';

const Primary = () => {
  return <Editor
    id='grapesjs-react'
    plugins={[

      'gjs-blocks-basic'
    ]}
  />;
};
export default Primary;

This is the error I get: Attempted import error: 'grapesjs-react' does not contain a default export (imported as 'Editor').

Tried using import Editor from 'grapesjs-react' and import {GEditor} from 'grapesjs-react' as well.

Not working in both React and Nextjs.

Here are the dependencies of React: "dependencies": { "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^11.2.7", "@testing-library/user-event": "^12.8.3", "grapesjs": "^0.17.19", "grapesjs-preset-webpage": "^0.1.11", "grapesjs-react": "^4.0.1-alpha", "react": "^17.0.2", "react-dom": "^17.0.2", "react-scripts": "4.0.3", "web-vitals": "^1.1.2" },

anuragk15 commented 3 years ago

Silly error. Was using wrong named import. It should be {GrapesjsReact}