wangzuo / input-moment

React datetime picker powered by momentjs
https://wangzuo.github.io/input-moment
ISC License
526 stars 172 forks source link

Cannot read property 'date' of undefined & npm install peer dep. unmet #44

Open yarnball opened 8 years ago

yarnball commented 8 years ago
  1. npm install react-moment --save

  2. npm i input-moment --save 2a. Above gives me the error:

    react-redux-firebase-login@0.1.0 /Users/mac1/Dev/A51/FrontendReact/FireRedux
    └─┬ input-moment@0.3.0 
    ├── blacklist@1.1.4 
    ├── lodash@3.10.1 
    ├── UNMET PEER DEPENDENCY react@^0.14.0
    ├── UNMET PEER DEPENDENCY react-dom@^0.14.0
    └── react-input-slider@1.5.0 
  3. Then my code is:

import Moment from 'moment'
import InputMoment from 'input-moment'

    render: function(){
        return (
    <InputMoment
  moment={this.state.moment}
  onChange={this.handleChange}
  onSave={this.handleSave}
/>
            );
    }
});

This returns the error in calendar.js Line 40 entitled:

Uncaught TypeError: Cannot read property 'date' of undefined(…)

bmulcahy commented 7 years ago

Don't you need moment installed not react-moment?

JeremyIglehart commented 7 years ago

I think this should be split into two different issues. I am also getting the error on line 40 where for some reason m is returning undefined.

lukasborawski commented 7 years ago

@wangzuo can you help with that? ths same issue with me :(

aviemet commented 5 years ago

I was getting this error also while just trying to do a simple test. Once I actually set up state.moment with a moment object and defined the handleChange and handleSave methods it functioned as expected. The need for these to be defined should probably be documented.

is-prashant commented 5 years ago

I have same isuue in calender.js, in line 45 it says cannot read property 'date' of undefined.

jnsandrew commented 5 years ago

I had the same issue to @JeremyIglehart and it was because I was missing the moment prop -

import moment from 'moment'

...

<InputMoment
    moment={moment()} // was missing
    //... other props
/>