1

Agenda doesn't update even when new data are added. Only when the app is reloaded it updates. Here is my code:

const CalendarScreen = () => {
const list = useSelector((state) => state.getTodo.list);
const [items, setItems] = useState({});
const loadItems = () => {
list.forEach((data) => {
  const strTime = data.createdDate;
  if (!items[strTime]) {
    items[strTime] = [];
    list.forEach((datalist) => {
      items[strTime].push({
        name: datalist.title,
      });
    });
  }
});
const newItems = {};
Object.keys(items).forEach((key) => {
  newItems[key] = items[key];
});
setItems(newItems);
};
const renderItem = (item) => {
  return (
    <View >
      <Text>{item.name}</Text>
    </View>
  );
};
return (
 <View style={flex: 1}>
    <Agenda
      items={items}
      loadItemsForMonth={loadItems}
      renderItem={renderItem}
      pastScrollRange={1}
      futureScrollRange={1}
    />
 </View>
 );
};
export { CalendarScreen };

Expectation: Just want the Agenda to update automatically when new data is added in the state instead of having to reload the app.

Cool Dunno
  • 31
  • 2

1 Answers1

0

It looks like that refresh depends call of loadItemsForMonth.

Unfortunately I cannot see when Agenda call loadItemsForMonth

Michael Bahl
  • 2,941
  • 1
  • 13
  • 16