Skip to main content

One post tagged with "react"

View All Tags

· 5 min read

Introduction

React offers two approaches for managing inputs: controlled and uncontrolled. Controlled inputs, where the input value is explicitly managed by React (typically using useState and handling changes with onChange()), allow for more complex scenarios and precise control. Uncontrolled inputs delegate this responsibility to the browser, resulting in a loss of fine-grained control over the component's behavior.

In React, controlled inputs are generally preferred because they integrate seamlessly with React's state management and lifecycle.

Problem

A potential issue with controlled inputs is performance degradation. This occurs because every keystroke triggers a rerender, which can affect the performance of the component and its siblings.