• Holkan

    (@cubeinthebox)


    Hello. I’ve been struggling with this for a while. I’m developing a plugin for Gutenberg, NOTICE: It’s not a block plugin but a sidebar plugin. It handles several post meta values and saves them after user interaction.
    The problem here is that I need to update one component based on the word count in the editor. Say, if there are more than 300 words in the content, then update the component.

    The question is: how can I hook into a post editor’s event in order to set the state ( this.setState({...}) ) before getDerivedStateFromRrops() lifecycle method is fired. I’ve tried componentDidUpdate(), but it’s fired after getDerivedStateFromRrops() and therefore none of my values gets updated.

    You can check the code here: https://github.com/HelaGone/Anlayze_SEO_react_plugin
    feel free to download it.

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Sorry, but I am finding your terminology unclear.
    Javascript is always browser side, it runs in your web browser.
    On the other hand plugins run in the server, their language is PHP, hooks are always PHP.
    There are various forms of communication between them, sometimes AJAX, othertimes by POST etc.
    Maybe clarifying the terminology and division of labor will help.

    Thread Starter Holkan

    (@cubeinthebox)

    Sorry, but I was writing a plugin with React not in the old fashion way which of course is php.

    • This reply was modified 7 years, 5 months ago by Holkan.
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to hook into post content edit with a javascript plugin’ is closed to new replies.