stephy / CalendarPicker

CalendarPicker Component for React Native
805 stars 373 forks source link

Slow on Day press #176

Closed estevanpedro closed 4 years ago

estevanpedro commented 4 years ago

When i click in the day, it's take too long to render the style, it's looks so slow, am i doing something wrong? I'm testing on my android device emulator

<Modal visible={modalVisible} animationType="slide" transparent={false}>
        <View style={styles.modalStyled}>
          <CalendarPicker
            maxDate={moment()}
            weekdays={['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab', 'Dom']}
            months={[
              'Janeiro',
              'Fevereiro',
              'Março',
              'Abril',
              'Maio',
              'Junho',
              'Julho',
              'Agosto',
              'Setembro',
              'Outubro',
              'Novembro',
              'Dezembro',
            ]}
            previousTitle="Anterior"
            nextTitle="Próximo"
            selectedDayColor="#1B83E0"
            selectedDayTextColor="white"
            //allowRangeSelection={true}
            onDateChange={(date: any, type: any) => {
              setActive_id(null);
              setOpenStyle(false);
              onDateChange(date, type);
            }}
          />
          <TouchableOpacity
            onPress={() => {
              setModalVisible(false);
              setRefresh(oldState => !oldState);
            }}
            style={styles.button}>
            <Text style={styles.textButton}> Confirmar </Text>
          </TouchableOpacity>
        </View>
      </Modal>
peacechen commented 4 years ago

I recommend that you performance profile the callback passed to onDateChange. You have a few calls that could cause multiple re-renders, but only you have access to that code to inspect.

Is it slow on a physical device, or only the emulator?

peacechen commented 4 years ago

Closing due to inactivity. Feel free to re-open if you have more information.