Tcomb-form-native: Unrecognized date picker format undefined

Created on 21 Feb 2018  路  7Comments  路  Source: gcanti/tcomb-form-native

Version

Tell us which versions you are using:

Expected behaviour

Was thinking dates would show date picker

Actual behaviour

Get error message "Unrecognized date picker format undefined"

Steps to reproduce

Tcomb forms working, added Date and got error.
Here's commit of code that generates error:

https://github.com/AgileVentures/MyNoteBoatPrototype/commit/decfd8aa28aaefc3ea09f0dc54be98b6457dc9c8

Stack trace and console log

Error: Unrecognized date picker format undefined

This error is located at:
    in Component (created by Component)
    in RCTView (at View.js:71)
    in View (at struct.js:32)
    in Component (created by Form)
    in Form (at TestVHFScreen.js:40)
    in RCTView (at View.js:71)
    in View (at TestVHFScreen.js:39)
    in TestVHFScreen (at SceneView.js:17)
    in SceneView (at CardStack.js:402)
    in RCTView (at View.js:71)
    in View (at CardStack.js:401)
    in RCTView (at View.js:71)
    in View (at CardStack.js:400)
    in RCTView (at View.js:71)
    in View (at createAnimatedComponent.js:147)
    in AnimatedComponent (at Card.js:12)
    in Card (at PointerEventsContainer.js:39)
    in Container (at CardStack.js:445)
    in RCTView (at View.js:71)
    in View (at CardStack.js:361)
    in RCTView (at View.js:71)
    in View (at CardStack.js:360)
    in CardStack (at CardStackTransitioner.js:67)
    in RCTView (at View.js:71)
    in View (at Transitioner.js:142)
    in Transitioner (at CardStackTransitioner.js:19)
    in CardStackTransitioner (at StackNavigator.js:39)
    in Unknown (at createNavigator.js:13)
    in Navigator (at createNavigationContainer.js:227)
    in NavigationContainer (at RootNavigation.js:37)
    in RootNavigator (at App.js:26)
    in RCTView (at View.js:71)
    in View (at App.js:23)
    in App (at registerRootComponent.js:35)
    in RootErrorBoundary (at registerRootComponent.js:34)
    in ExpoRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:71)
    in View (at AppContainer.js:102)
    in RCTView (at View.js:71)
    in View (at AppContainer.js:122)
    in AppContainer (at renderApplication.js:34)
datepicker
    datepicker.android.js:60:5
render
    components.js:223:1
proxiedMethod
    createPrototypeProxy.js:44:35
finishClassComponent
    ReactNativeRenderer-dev.js:7866:21
updateClassComponent
    ReactNativeRenderer-dev.js:7834:6
beginWork
    ReactNativeRenderer-dev.js:8285:10
performUnitOfWork
    ReactNativeRenderer-dev.js:10513:25
workLoop
    ReactNativeRenderer-dev.js:10584:43
_invokeGuardedCallback
    ReactNativeRenderer-dev.js:134:15
invokeGuardedCallback
    ReactNativeRenderer-dev.js:67:32
renderRoot
    ReactNativeRenderer-dev.js:10677:30
performWorkOnRoot
    ReactNativeRenderer-dev.js:11449:34
performWork
    ReactNativeRenderer-dev.js:11364:8
batchedUpdates
    ReactNativeRenderer-dev.js:11547:20
batchedUpdates
    ReactNativeRenderer-dev.js:2517:31
_receiveRootNodeIDEvent
    ReactNativeRenderer-dev.js:2670:17
receiveTouches
    ReactNativeRenderer-dev.js:2741:28
__callFunction
    MessageQueue.js:353:47
<unknown>
    MessageQueue.js:118:26
__guardSafe
    MessageQueue.js:316:6
callFunctionReturnFlushedQueue
    MessageQueue.js:117:17

Most helpful comment

Solved - you have to ensure you've set the mode.

const options = {
  fields: {
    eta: {
      label: 'ETA',
      mode: 'date',
      config: {
        format: (date) => moment(date).format('YYYY-mm-d'),
      },
    },
  },
};

All 7 comments

+1 same here with absolutely same stack trace. Any fixes ?

Getting the same, only with Android (iOS is fine)

Solved - you have to ensure you've set the mode.

const options = {
  fields: {
    eta: {
      label: 'ETA',
      mode: 'date',
      config: {
        format: (date) => moment(date).format('YYYY-mm-d'),
      },
    },
  },
};

@Itankey : Thank you so much ! It works now !

Hey @ltankey

I don't understand what moment is? in Config
Im getting moment is not defined ReferenceError

@sourabhdadapure :
Moment is a library. You gotta install it through npm install moment --save. And import moment in your code.

moment is not strictly necessary to format the date. You just need to provide a format function with the following signature:

(date: Date) => string

Anything with this will work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dvlprmartins picture dvlprmartins  路  4Comments

casoetan picture casoetan  路  5Comments

sibelius picture sibelius  路  4Comments

abdelghafourzguindou picture abdelghafourzguindou  路  4Comments

alexicum picture alexicum  路  6Comments