Closed github-jeff closed 3 years ago
This should work... using NextJs's way of dynamically importing a package on the client only
import dynamic from "next/dynamic";
const SimpleMdeEditor = dynamic(
() => import("react-simplemde-editor"),
{ ssr: false }
);
<SimpleMdeEditor
value={post.content}
onChange={value => setPost({ ...post, content: value })}
/>
Many thanks @modikum I can confirm this works great.
A few notes:
import SimpleMDE from "react-simplemde-editor"
and replace with:
import dynamic from "next/dynamic";
Place this section just above the return section in the functions "createpost" and "editpost" respectively
const SimpleMdeEditor = dynamic(
() => import("react-simplemde-editor"),
{ ssr: false }
);
This:
<SimpleMdeEditor
value={post.content}
onChange={value => setPost({ ...post, content: value })}
/>
is the same as:
<SimpleMDE value={post.content} onChange={value => setPost({ ...post, content: value })} />
which is already in the code provided, but in my (opinion) it's easier to read with the indented format.
Lastly, delete tailwind.config.js and run:
npx tailwindcss init --full
then add back in the plugin as specified in the tutorial
ref: tailwindcss: issue 2810
I was not able to use npx serverless unless I added the credentials to the .bashrc file. ref Calling AWS services from an environment in AWS Cloud9
@modikum her solution worked great. TY.
Excellent tutorial.
Also more as a heads up there is an issue with amazon cloud9 IDE (default) and it's detailed in tailwind issue Issue: 2810
(it reports as easymde):
I thought the real problem is Node 10x is installed by default on cloud9 IDE machines. It is made note of in the prerequisites which was read but not actually checked on the EC2 machine. To correct, I used the following guide. Upgrade Node
However the build problems continued, and this is where I became jammed up.
I have tried:
npm install codemirror
with the import:import CodeMirror from 'codemirror';
in both create-post.js and edit-post/[id].jsI have also tried:
npm install easymde
Any help would be appreciated.
Update: I have narrowed this down to this include
import SimpleMDE from "react-simplemde-editor
Update 2: I have also tried:
uiwjs/react-md-editor
Also failed to compile.