I want to execute code in my useEffect method only when productType is changed, and as soon as page loaded I can recognized console.log is executed more than 6-7 times which is what I don't want.
Here is summary of my code:
const [productType, setProductType] = useState(null); useEffect(() => { console.log(productType); }, productType); Idea is to execute code in this useEffect when productType changes, I'm changing it on dropdown like this:
<MyDropdownComponent value={productType} onChange={e => setExportType(e.target.value)} width={200} /> So I'm wondering why when I load this view/template, I got like 6-7-8 console.logs of null in my console..