March 2019
Intermediate to advanced
534 pages
14h 52m
English
The two Select components in this example have state dependencies. That is, the state of the product select depends on the state of the category select. This is because the options displayed in the product select are filtered based on the chosen category. Let's take a closer look at the state:
const [categories, setCategories] = useState([ { label: 'Category 1', id: 1 }, { label: 'Category 2', id: 2 }, { label: 'Category 3', id: 3 }]);const [products, setProducts] = useState([ { label: 'Product 1', id: 1, category: 1 }, { label: 'Product 2', id: 2, category: 1 }, { label: 'Product 3', id: 3, category: 1 }, { label: 'Product 4', id: 4, category: 2 }, { label: 'Product 5', id: 5, category: 2 }, { label: 'Product 6', id: 6, category: ...Read now
Unlock full access