I tried like this load from Redux:
if (!itemsWithSelection) {
useAppSelector((state) => {
setItemsWithSelection(state.startPaymentIn.invoiceItems);
});
}
then I got this error:
Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
If I do like this:
const [itemsWithSelection, setItemsWithSelection] = useState<
InvoiceItemDataOnBuyTicket | undefined
>(useAppSelector((state) => state.startPaymentIn.invoiceItems));
then data will not available when page is rendered in return function.
What would you suggest?