Controlled vs Uncontrolled Form.Control in React Bootstrap
Choose controlled or uncontrolled Form.Control inputs in React Bootstrap, with version checks, code examples, and validation guidance.
09 Sept 2026, 11:29 UTC

Problem and takeaway
You are adding a form to a React application with React Bootstrap, and each Form.Control raises the same question: should the input value live in React state or in the DOM? Choosing the wrong mode makes validation harder, triggers extra re-renders, or produces a React console warning.
Takeaway: use controlled inputs when your submit button, validation message, or another field depends on the current value. Use uncontrolled inputs for long forms or when a non-React library owns the form. Never pass value and defaultValue to the same Form.Control.
Decision and constraints
React Bootstrap v2 and v3 expect Bootstrap 5 CSS. Version 1.x targeted Bootstrap 4, so markup and utility classes are version-sensitive. Before choosing an input mode, confirm these constraints:
- You are using React Bootstrap v2 or v3 with Bootstrap 5.
- Each Form.Control is either controlled (value plus onChange) or uncontrolled (defaultValue only), never both.
- You know whether validation, submit-button state, or other fields must react to every keystroke.
Controlled versus uncontrolled inputs
| Concern | Controlled | Uncontrolled |
|---|---|---|
| Value source | React state bound to value | The DOM, initialized with defaultValue |
| Update trigger | onChange updates state, then React re-renders the input | User typing updates the DOM directly |
| Validation | Straightforward; validate in onChange or on submit | Harder to validate before submit without a ref |
| Re-renders | Potentially one per keystroke on the form owner | Fewer React updates for large forms |
| Reset behavior | Reset by updating state | Reset by resetting the form element or ref |
| Best for | Validation, dependent fields, conditional submit buttons | Long forms, simple capture, non-React form libraries |
Trade-offs to consider
Controlled inputs make React state the single source of truth. That simplifies enabling a submit button only when an email field passes validation. The cost is a state update and potential re-render on every keystroke. In a form with many fields, that can feel sluggish if the parent component re-renders unnecessarily.
Uncontrolled inputs let the browser own the value. Typing does not force React to reconcile state, which helps long forms. The trade-off is that reading the value requires a ref or form submission, so real-time validation is more awkward.
Implementation: controlled input
This example keeps email in state, validates on every change, and disables the submit button until the value looks valid.
import { useState } from 'react';
import { Form, Button } from 'react-bootstrap';
export default function ControlledSignup() {
const [email, setEmail] = useState('');
const [error, setError] = useState(null);
const handleChange = (event) => {
const value = event.target.value;
setEmail(value);
setError(value.includes('@') ? null : 'Enter a valid email');
};
const handleSubmit = (event) => {
event.preventDefault();
if (!email.includes('@')) return;
// submit logic here
};
return (
Email
{error}
Sign up
);
}
Implementation: uncontrolled input
This example uses defaultValue and reads the value through a ref only when the form submits.
import { useRef } from 'react';
import { Form, Button } from 'react-bootstrap';
export default function UncontrolledSignup() {
const emailRef = useRef(null);
const handleSubmit = (event) => {
event.preventDefault();
const value = emailRef.current?.value;
if (!value.includes('@')) {
alert('Enter a valid email');
return;
}
// submit logic here
};
return (
Email
Sign up
);
}
Verify dependency versions
Run this in a terminal at your project root. No special permissions are required. Replace with your actual directory.
cd
npm list react-bootstrap bootstrap
Expected result: react-bootstrap appears as version 2.x or 3.x, and bootstrap appears as version 5.x. If react-bootstrap is v2 or v3 but bootstrap is v4, component styling and responsive behavior can break. Installing or changing packages modifies node_modules; to revert, restore package.json and package-lock.json from Git and reinstall.
Practical verification
- Render the controlled component. Type one character. The input should update after React processes the state change, and the submit button should reflect the validation state immediately.
- Render the uncontrolled component. Type one character. The DOM updates without a React state change, and the value is available only through the ref or submit handler.
- Open browser DevTools and check the Console. There should be no warning about mixing controlled and uncontrolled inputs. If you see a warning mentioning value and defaultValue, remove one of those props from Form.Control.
Limitations
- Controlled inputs can cause parent re-renders on every keystroke. For long forms, consider uncontrolled fields for data that does not need immediate validation, or debounce the change handler.
- Uncontrolled inputs make conditional UI, such as disabling a submit button while typing, difficult without extra refs or event listeners.
- Mismatched react-bootstrap and Bootstrap CSS versions break component styling and responsive behavior.
Bottom line: match the input mode to the form's validation needs, keep React Bootstrap and Bootstrap CSS on compatible major versions, and never supply value and defaultValue to the same input.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.