Skip to main content
InterviewHubPRO
Section Overview
Q332

Question 332 of 407

Part 9: React Hooks Deep Dive (262 - 316)

82%
React Core & Hooks (407 Qs)•Part 9: React Hooks Deep Dive (262 - 316)

How to set state with a dynamic key name?

mid LevelCode ExampleHooks

If you are using ES6 or the Babel transpiler to transform your JSX code then you can accomplish this with computed property names.

javascript
    handleInputChange(event) {
      this.setState({ [event.target.id]: event.target.value })
    }