As I work on a react component, I am interested in passing a reference to a field within an interface. When working with interfaces, such as the example below:
interface Person {
name: String
}
I want to pass a ref specifically for accessing Person::name. This way, I can easily set this field within the component without having to write additional code each time. While I could achieve this with a function like (p: Person) -> p.name = "the name", it feels like unnecessary boilerplate.
Passing "name" as a string is another option, but it opens the door for misspellings or refactoring issues. My goal is to leverage type safety for efficiency and accuracy.
Thank you!