Closed
Description
i use nextjs, and i intalled the latest version : react-simplemde-editor 5.0.1
i lose focus when i type and i had registered onChange.
issue #150 speaks about the same problem but i use class, not hooks.
sample code can be this :
import { withAuthSync } from '../utils/auth.js';
import React, { Component } from 'react';
import Layout from '../components/Layout.js';
import Head from 'next/head';
import PropTypes from 'prop-types';
import dynamic from 'next/dynamic';
const SimpleMDE = dynamic(() => import('react-simplemde-editor'), {
ssr: false,
});
class Editor extends Component {
static propTypes = {
me: PropTypes.object,
post: PropTypes.object,
};
constructor(props) {
super(props);
this.state = {
content: 'content',
};
}
render() {
console.log('render', this.state);
return (
<Layout me={this.props.me}>
<Head>
<title>{this.state.name || 'editor'}</title>
<link href="https://unpkg.com/easymde/dist/easymde.min.css" rel="stylesheet" />
<link href="https://unpkg.com/react-toastify/dist/ReactToastify.css" rel="stylesheet" />
</Head>
<SimpleMDE
value={this.state.content}
onChange={(value) => this.setState({ content: value })}
options={{ indentWithTabs: false, tabSize: 4 }}
/>
</Layout>
);
}
}
export default withAuthSync(Editor);
Metadata
Metadata
Assignees
Labels
No labels