Authors:
Cameron Johns, Cille Schliebitz, Anita Gu
Changed on:
3 Feb 2025
`QuantitySelector`. We'll also cover best practices like using the `useEffect` hook for debugging.`useEffect`: Use the `useEffect` hook to debug and verify the behavior and output of your custom field.1const useStyles = makeStyles((theme) => ({
2 locationWrapper: {
3 display: 'flex',
4 flexDirection: 'column',
5 },
6 radioWrapper: {
7 marginRight: 0,
8 '&:hover': {
9 color: theme.palette.primary.main,
10 },
11 },
12 locationLabelWrapper: {
13 width: '100%',
14 },
15 splitColumns: {
16 display: 'flex',
17 flexDirection: 'row',
18 justifyContent: 'space-between',
19 },
20 availableQty: {
21 color: '#94d096',
22 fontWeight: 'bold',
23 },
24 quantitySelectorContainer: {
25 marginBottom: '20px',
26 },
27 quantityLabel: {
28 marginBottom: '10px',
29 color: '#909090',
30 },
31 }));`quantity` property of the `StockReservationPayload`—the value should be a positive integer. We have an existing control in the component library for this purpose, so we can use that component within our new field.`quantity` value. [0:28]`QuantitySelector` field component from the `FieldRegistry` using its alias "number". [0:56]`QuantitySelector` component to the `div` with the `quantitySelectorContainer` class, and set the `name`, `label`, `value`, and `onChange` handler. [1:33]`useEffect` hook. [2:45]