How can I change the state of a component when another changes?
When the state of a select changes AssetType, the value of the select AssetTypeCategory must be set to 0
const handleAssetType = (e)=>{
setAssetType(e.target.value),
setAssetTypeCategory(0),
}
<div>
<label htmlFor="AssetType>Asset Type:</label>
{Array.isArray(state.AssetType) ? (
<select
name="AssetType"
id="AssetType"
value={state}
onChange={handleAssetType }
>
<option key="0" value="0">
-- PICK A ITEM--
</option>
{state.AssetType.map((x) => (
<option key={x.id} value={x.id}>
{x.name}
</option>
))}
</select>
) : null}
</div>