Lift State Up
React
Junior
State managementUnidirectional data flow
Build a Percentage Controller with two sibling sliders that both control one shared percentage, reflected in a horizontal bar.Requirements
- Initial value is 50%.
- Each slider is an
<input type="range" min="0" max="100">withdata-testid="slider-1"anddata-testid="slider-2". - Moving either slider instantly updates both thumbs and the bar fill.
- Bar wrapper is
data-testid="bar", inner fill isdata-testid="bar-fill"with inline stylewidth: "${percentage}%".
Notes
- Do not edit
data-testidattributes (used for testing).
import PercentageController from "./PercentageController"; export default function App() { return ( <div className="min-h-screen flex items-center justify-center bg-gray-50 p-6"> <PercentageController /> </div> ); }
JavaScript Console
console.log()statements will appear here
Tests
AI Analyzer