Comments (6)
Glad it worked.
but doing the same with the confirmation button didnt work
Probably because the cancel button doesn't return any parameter (so you can handle it even without the onCancel
), while the confirm button returns the time (that is handled by onConfirm
).
from react-native-modal-datetime-picker.
Hey @temitope,
ad you can see here I'm already wrapping your custom button with a TouchableOpacity
.
This means that you should remove your onPress
prop from your component and simply use the onConfirm
prop (of react-native-modal-datetime-picker
) just like you'll do with the build-in confirm button.
Let me know if it fixes your issue :)
from react-native-modal-datetime-picker.
ahh yes, that makes sense. but im still not getting the desired behavior. It may be because I am using the Button component from the [https://github.com/react-native-community/react-native-elements](react-native-elements module? [ https://github.com/react-native-community/react-native-elements) ]
I am getting a debug message of
please attach method to this component
from line 12 in the Button.js of that module...hmm i shouldnt need it to be their button, i will try the native buttons not in the module as well.
P.S. it is maybe a little incongruous with the customCancelButtonIOS property and onCancel, in that i think i had to create an onPress attribute and call a function to have it close (it does not seem to autocarry the onCancel prop), then again i am a React newbie and could be missing something about syntax/paradigm shift of React itself
from react-native-modal-datetime-picker.
First of all: yes, that log line is indeed caused by the button you're using.
Honestly I didn't understand you question regarding customCancelButton
🤔 ...
Basically both customCancelButtonIOS
and customConfirmButtonIOS
are simple views that you can pass to react-native-datetime-picker
and they will trigger onCancel
/ onConfirm
when pressed.
The button press interactions are handled internally by react-native-datetime-picker
and you should not pass a button with an already defined onPress
(like you were doing).
Try to pass a simple styled <View />
to customConfirmButtonIOS
: you'll see that it will trigger onConfirm
when pressed :)
I'm going to sleep now, if you have any more question I'll answer them tomorrow!
from react-native-modal-datetime-picker.
Boom! Passing in a simple View with some text did the job. Thanks for the help there.
this is maybe moot now, but to give more clarity regarding the customCancelButton
, i was saying that I was able to actually pass an event to the onPress handler using that react-native-element button and have everything worked just fine, but doing the same with the confirmation button didnt work so i didnt suspect that the type of element i was passing in was the issue, since it worked for one and not the other.
from react-native-modal-datetime-picker.
Hi there,
this solution is not working for me i am giving the simple view but it's not triggering to the onConfirm function automatically
<DateTimePickerModal
isVisible={isDatePickerVisible}
mode="date"
dateFormat="dayofweek day month"
onConfirm={date => {
handleConfirmShedule(date);
}}
onCancel={hideDatePicker}
textColor={Theme.primaryColor}
style={styles.datePicker}
confirmTextIOS="Done"
customConfirmButtonIOS={() => {
return (
<View
style={{
justifyContent: 'center',
alignItems: 'center',
marginBottom: 10,
height: 50,
width: '100%',
backgroundColor: 'red',
}}
>
);
}}
//backdropStyleIOS={{backgroundColor: 'transparent'}}
/>
from react-native-modal-datetime-picker.
Related Issues (20)
- iOS keyboard input for mode="time" breaks the UI HOT 3
- Native module RNDatePicker tried to override RNDatePicker
- Customizing Background and Text Color in Android with Expo HOT 2
- Minimum and maximum time is not working on android but working for ios
- MinuteInterval time return current time in ios , android working fine
- `onHide` callback doesn't return a valid Date
- timeZoneOffsetInMinutes` is deprecated and will be removed in a future release. Use `timeZoneName` instead.
- Datepicker is not visible on iOS HOT 1
- Can't see the text in the picker modal (iOS) HOT 1
- Missing peerDependency on React
- how can only use it as only Month and year picker
- react-native-modal-datetime-picker(^17.1.0) is not showing on iOS 17.3.1 HOT 1
- Exception in HostFunction: Malformed calls from JS: field sizes are different.
- Can't install in react-native 0.74 using NPM I HOT 1
- Dark Mode is not working on Android devices.
- Time Zone Issue HOT 1
- WARN: `defaultProps` will be removed from memo components HOT 3
- isDarkModeEnabled doesn't work on spinner in iOS
- how to add a custom header in Android
- WARN: defaultProps will be removed from memo components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-modal-datetime-picker.