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.

How to open calendar componet by click on a text

See original GitHub issue
<Text onPress={_pressHere} >
Select date
</Text>

var _onPress = () => {
        return (
            <MyDatePicker/>
        )
    };

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
Tinysymphonycommented, Feb 10, 2017

@nimamyscreen @appsthatmatter My example was deleted accidentally…sorry for that here is the code

let customStyles = {
  dateInput: {
    width: 0,
    height: 0,
    borderWidth: 0
  }
};
// in render function
<Text
  onPress={() => {this.refs.datepicker.onPressDate()}}>
  Your Text
</Text>
<DatePicker
  style={{width: 0, height: 0}}
  showIcon={false}
  customStyles={customStyles}
  ref="datepicker"
/>

hide icon by showIcon={false}, hide datepicker’s touchable view by style={{width: 0, height: 0}}, hide inputBody view by customStyles and use ref as a hook. (PS. kind of tedious…)

@nimamyscreen you can learn more about ref through this document

7reactions
Tinysymphonycommented, Feb 10, 2017

@nimamyscreen save the ref in a temporary variable will work.

// define a variable in outside scope that both components can access
let myDatepicker;

// in text render function
<Text onPress={() => myDatepicker && myDatepicker.onPressDate(); }>Press Date</Text>

// in datepicker render function 
<DatePicker
  ref={(datepicker) => myDatepicker = datepicker;}
/>

In onPress callback, you’d better test whether myDatepicker is defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

open a componet by click on text in react native - Stack Overflow
open a componet by click on text in react native ... I want to open a calendar component when I click on a...
Read more >
How to show calendar only click on icon using JavaScript
How to show calendar only click on icon using JavaScript ?
Read more >
How to click calendar from text - Activities - UiPath Forum
I want to click text from calendar in day = 1 but it error not found. Guide me please.
Read more >
Datepicker - Angular Material
The datepicker allows users to enter a date either through text input, or by choosing a date from the calendar. It is made...
Read more >
Date picker component — Vuetify
By default the current date is displayed using outlined button - show-current prop allows you to remove the border or select different date...
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