v2 using hooks
See original GitHub issueI wrote my own implementation of React container for Editor.js, and instead of creating separate package I’d like to volunteer my contributions and help here. Example use case would look like:
import { Editor, useEditorRef } from 'react-editor-js'
const MyComponent = ({ initialData }) => {
const [ref, { save, loading /* etc. */ }] = useEditorRef()
const onSave = useCallback(async () => {
const values = await save()
console.log(values)
}, [])
return (
<Editor ref={ref} data={initialData} holder="editor-js" /* etc. */>
{ !loading && <button onClick={onSave}>Save</button> }
)
}
Where useEditorRef is optional and can be replaced with standard useRef. That will allow you to access EditorJS instance with all standard methods at ref.current.
Does this sound like a good idea for this repo?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Introducing Hooks
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. ... This...
Read more >@apollo/react-hooks - Apollo GraphQL Docs
A GraphQL query document parsed into an AST by graphql-tag . Optional for the useQuery Hook since the query can be passed in...
Read more >useState, useCallback, useEffect - React Native v2
Hooks are placed inside the component, as high as possible, always above the return statement. The useState hook returns an array of two...
Read more >React Hooks cheat sheet: Best practices with examples
In this tutorial, we'll outline some React Hooks best practices and highlight some use cases with examples, from simple to advanced scenarios.
Read more >The Guide to Learning React Hooks (Examples & Tutorials)
Learn all about React Hooks with this hands-on guide. Includes tutorials and code examples on using hooks for state and effects, for context...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Appreciate the example @Jungwoo-An!
Just wanted to add an auto-save version I adapted in case others find this issue.
@Tymek Hi! First of all, thanks for your interest! 😍
I thought about this proposal, but i think it is not necessary feature. because It can already use with the react hook. (Example)
Thanks!