0

I'm trying to write a Chrome Snippet to interact with a React page - it takes some JSON data and fills out a form. The problem is, programmatically setting the value of various inputs doesn't update their React state. If there's any interaction which re-renders the component, the data is lost.

I'm wondering if there is any hack I can make use of to trigger the React state update. I tried triggering 'change' and 'keyup' events on the inputs but that didn't work.

In case it wasn't clear, I don't have any access to the page's React code at all. I don't own it or maintain it.

T Nguyen
  • 3,309
  • 2
  • 31
  • 48
  • 1
    What do you mean by a "Chrome Snippet"? do you mean Chrome Extension or just javascript you can run in the console? – Eagnir Dec 29 '22 at 23:39
  • @Eagnir, a Chrome Snippet is a bit of code that you can save to Chrome Dev Tools and run on demand. But functionally, it is equivalent to anything you can do in the console. So imagine, you use vanilla JS in the console to set a text field value, but the React component isn't updated. – T Nguyen Dec 29 '22 at 23:41
  • Thanks for the clarification. Could you setup a [react fiddle](https://jsfiddle.net/boilerplate/react-jsx) for the website being manipulated, so I have a boiler plate of what you are working with. – Eagnir Dec 29 '22 at 23:59

0 Answers0