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.

3
  • 1
    What do you mean by a "Chrome Snippet"? do you mean Chrome Extension or just javascript you can run in the console? Commented Dec 29, 2022 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. Commented Dec 29, 2022 at 23:41
  • Thanks for the clarification. Could you setup a react fiddle for the website being manipulated, so I have a boiler plate of what you are working with. Commented Dec 29, 2022 at 23:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.