Dynamic onChange call for UI rendering via UI Extension

I am trying to find a solution to create a dynamic rendering of the entry content with field lock functionality in Contentful. I was trying out with the “entry-editor-extension” example (which is not dynamic) and modifying it to render the fields dynamically however I have come across an issue to set the value in the backend. Here is the screen shot of how the onChangeHandler function looks like:

This is how I have passed the item as a string name to parse through the particular item and set its value on the backend of Contentful. This creates an error and says “Cannot set the value of undefined”. I know that since the “const fieldname” is greyed out. That const is not being used for parsing through the field and is trying to find the object “fieldname” inside the fields.

Again if I try using the bracket method. Still gives me error:
However, when I parse through particular field on the entry (not dynamically) it works fine:

onTextareaChangeHandler = (event: React.ChangeEvent<HTMLInputElement>) => {