Saving expenses

The next step is to allow entries to be saved to the app. Let's modify AddExpensesModal again and add the following features; you will also need to add some methods into storageMethods as well as the AddExpenses component:

  • A button to save the expense, with the following conditions:
    • It should only be enabled if all the fields of the modal are filled out.
    • When pressed, the expense name, amount, and date should be saved into AsyncStorage.
    • The date should be formatted with Moment the same way we formatted it for the ExpandableCell title.
    • When this logic finishes, the modal should be closed and the information entered should be cleared. The closing of the modal should be passed in as a prop from the parent AddExpenses component ...

Get React Native By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.