Both over- and underreaction to information are well-documented empirically across a variety of domains. This paper explores how key features of the learning environment determine which bias emerges in a given setting. We first develop a two-stage model of belief formation. In the editing stage, limited attention leads the agent to use the representativeness heuristic to simplify the learning environment. In the evaluation stage, the agent forms subjective beliefs based on a noisy representation of the edited information structure. This model predicts underreaction when the state space is simple, signals are precise, and the prior is flat or diffuse; it predicts overreaction when the state space is complex, signals are noisy, and the prior is concentrated. A series of experiments provides direct support for these theoretical predictions. As a stark example, increasing the complexity of the state space from two to three states completely reverses the direction of the bias from underreaction to overreaction. The results highlight that both stages of belief updating are crucial, in that neither stage on its own can explain the observed patterns in the data. Our framework also rationalizes the disparate findings in prior work: the model predicts the prevalence of underreaction in laboratory studies—which typically use a binary state space, relatively informative signals, and flat priors—as well as the predominance of overreaction documented in financial markets—which feature a more complex state space and noisier signals.