Add db change listener
This commit is contained in:
+4
-2
@@ -4,14 +4,16 @@ import { Calendar } from 'react-native-calendars'
|
|||||||
import * as styles from './styles'
|
import * as styles from './styles'
|
||||||
import { getOrCreateCycleDay, bleedingDaysSortedByDate } from './db'
|
import { getOrCreateCycleDay, bleedingDaysSortedByDate } from './db'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default class DatePickView extends Component {
|
export default class DatePickView extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
cycleDays: bleedingDaysSortedByDate
|
cycleDays: bleedingDaysSortedByDate
|
||||||
}
|
}
|
||||||
|
// so we rerender the calendar when there are new bleeding days
|
||||||
|
bleedingDaysSortedByDate.addListener(() => {
|
||||||
|
this.setState({ cycleDays: bleedingDaysSortedByDate })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
passDateToDayView(result) {
|
passDateToDayView(result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user