question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selectables week numbers

See original GitHub issue

Description

When running the example app, pressing one of the week numbers on the Calendar with week numbers example causes the app to crash.

Expected Behavior

The week numbers should not be selectable ( behaving like other markings, such as the weekday names on the top)

Observed Behavior

Selecting the week number triggered the onPress prop to trigger when it was not defined for the week numbers, causing the example app to crash.

Error output from the console:

ExceptionsManager.js:65 this.props.onPress is not a function
handleException	@	ExceptionsManager.js:65
handleError	@	InitializeCore.js:115
reportFatalError	@	error-guard.js:44
__guardSafe	@	MessageQueue.js:318
callFunctionReturnFlushedQueue	@	MessageQueue.js:117
(anonymous)	@	debuggerWorker.js:72

Environment

  • npm ls react-native-calendars: react-native-calendars@1.17.3
  • npm ls react-native: react-native@0.53.3

Also specify:

  1. Phone/emulator/simulator & version: Simulator Version 10.0 (SimulatorApp-835.5 CoreSimulator-494.33)
  2. OS: macOS High Sierra 10.13.3

Reproducible Demo

The error can be observed on the example app present on the repository, but here follows a minimal reproducible version:

import React, {Component} from 'react';
import { StyleSheet, View } from 'react-native';
import {Calendar} from 'react-native-calendars';

export default class CalendarsScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {};
    this.onDayPress = this.onDayPress.bind(this);
  }

  render() {
    return (
      <View style={styles.container}>
        <Calendar
          onDayPress={this.onDayPress}
          style={styles.calendar}
          hideExtraDays
          showWeekNumbers
          markedDates={{[this.state.selected]: {selected: true}}}
        />
      </View>
    );
  }

  onDayPress(day) {
    this.setState({
      selected: day.dateString
    });
  }
}

const styles = StyleSheet.create({
  calendar: {
    borderTopWidth: 1,
    paddingTop: 5,
    borderBottomWidth: 1,
    borderColor: '#eee',
    height: 350
  },
  container: {
    flex: 1,
    backgroundColor: 'gray'
  }
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tautvilascommented, Mar 13, 2018

resolved v1.17.4 thanks for PR

0reactions
rdewolffcommented, Mar 17, 2020

Nope, built my own week calendar to have more flexibility.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to select only a week number and a year ...
A week number is not selectable. However, you can implement one of the following solutions to select all days in a clicked week:...
Read more >
Solved: How to calculate week number? - Page 4
Solved: Im creating a small booking app, where the users are used to Weeknumbers. Is it posible to spesify like : Week :...
Read more >
Javascript Calendar Week selection Example
Define the number of days - The selectSize option can be any number, where 3 means three days, 7 means a week and...
Read more >
<input type="week"> - HTML: HyperText Markup Language
The latest (time-wise) year and week number, in the string format ... 2017 will be seen as valid and be selectable in supporting...
Read more >
Calendar Week Number in status - Apps on Google Play
This App shows you the Calendar Week Number directly in the Notification Bar, thats it The Work Week is shown also inside the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found