- Read the short React guide on Components and Props
- Read the short React guide on State and
Lifecycle stopping when
you get to the
Adding Lifecycle Methods to a Class
section (the rest isn't relevant for this portion of work) - In
index.js
, turnAwardeeMap
into a class-based React component - Initialize a
state
attribute, an object containing amarkers
array, inAwardeeMap.constructor()
-- we'll use this attribute to track the marker state for both the search box and the map - In the function assigned to the
render
prop of theStaticQuery
inAwardeeMap
, refactor the function calls that generateCircleMarkers
for each marker so that the markers can be generated by a single component,AwardeeMarkers
:
<AwardeeMarkers markers={this.state.markers} />
(This will probably require creating a couple extra components to render different popups depending on whether the marker is a Driehaus or CNDA marker. Give this a try, and if you get stuck, refer to the React guide on Conditional Rendering for hints.)
- Read the React docs on Lifting State Up
- In
search.js
, refactor the component similar to the way they refactor theCalculator
in the React guide, so that the search updates results using a function calledthis.props.onSearchChange()
on submit (we'll define that function next) - In
index.js
, add a method toAwardeeMap
calledonSearchChange()
that accepts a set of search results and updates theAwardeeMap
state to set a new list ofmarkers
based on the search results - In
index.js
, update the search box component to initialize with anonSearchChange
prop corresponding toAwardeeMap.onSearchChange()
-
At the start of the function assigned to the
render
prop of theStaticQuery
inAwardeeMap
, initialize a variableallMarkers
as the concatenation of the Driehaus and CNDA winner arrays and passit into the
AwardeeMarkers
component -
Update the
AwardeeMarkers
component so that it falls back to theallMarkers
prop when themarkers
prop is empty