Title: How to hook into post content edit with a javascript plugin
Last modified: December 28, 2018

---

# How to hook into post content edit with a javascript plugin

 *  [Holkan](https://wordpress.org/support/users/cubeinthebox/)
 * (@cubeinthebox)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/how-to-hook-into-post-content-edit-with-a-javascript-plugin/)
 * 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](https://github.com/HelaGone/Anlayze_SEO_react_plugin)
   
   feel free to download it.
 * Thanks in advance!
    -  This topic was modified 7 years, 5 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/how-to-hook-into-post-content-edit-with-a-javascript-plugin/#post-11043347)
 * 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](https://wordpress.org/support/users/cubeinthebox/)
 * (@cubeinthebox)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/how-to-hook-into-post-content-edit-with-a-javascript-plugin/#post-11080201)
 * 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](https://wordpress.org/support/users/cubeinthebox/).

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.

## Tags

 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [Holkan](https://wordpress.org/support/users/cubeinthebox/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/how-to-hook-into-post-content-edit-with-a-javascript-plugin/#post-11080201)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
