About this deal
Text and number inputs provide the most straightforward example of using refs. In the ref attribute of the input, add an arrow function that takes the input as an argument. I tend to name the argument the same as the element itself as seen on line 3 below:
This pattern is a bit mind bending, so stare at it for a while and play around with the code until it sinks in. The "Toggle Vice-County" selector turns a Vice-County boundary on or off each time that county is selected. name="petType">
Above you see a form component RefForm, and an input component called CustomInput. Usually, the arrow function is on the input itself, but here it’s being passed down as a prop (see lines 15 and 27). Since the arrow function resides in the parent, the this of this.firstName lives in the parent. The value of the child input is being assigned to the this.firstName property of the parent, so the child’s value is available to the parent. Now, in the parent, this.firstName refers to a DOM node in the child component (i.e. the input in CustomInput). If you haven't got OS Maps or OS Locate or you're using a paper map, it is easy to find a particular place using a grid reference. To start, a four-figure grid reference is a handy way of identifying any square on a map. Grid references are easy if you can remember that you always have to go along the corridor before you go up the stairs. To find the number of a square first use the eastings to go along the corridor until you come to the bottom left-hand corner of the square you want. Total Zone Rating and initial framework for Wins above Replacement calculations provided by Sean Smith.
input type="radio" value="ferret" name="pet" />
Multiple VCs can be displayed. If you want to clear all the VCs, select the second option "Clear Vice-Counties". The downside to controlled components is the amount of code you have to write. You need a state property to pass to the form element as props, and you need a function to update the value of this property.