I want to call notification api when the notification count change.
const [data, setData] = useState('');
const [filteredDataSource, setFilteredDataSource] = useState([]);
useEffect(()=>{
getData({});
},[filteredDataSource]);
const getData = async () => {
axios
.get(`${BASE_URL}/Notification/getnotification`, {
headers: {
Authorization: `bearer ${accesstoken}`,
},
})
.then(({data}) => {
setData(data['0'].NotificationCount);
setFilteredDataSource(data);
});
this is working but every time the api was called.its make my app slow.only i want when the count increase or decrese then api call