input-moment icon indicating copy to clipboard operation
input-moment copied to clipboard

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

Open yarnball opened this issue 8 years ago • 6 comments

  1. npm install react-moment --save
  2. npm i input-moment --save 2a. Above gives me the error:
[email protected] /Users/mac1/Dev/A51/FrontendReact/FireRedux
└─┬ [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── UNMET PEER DEPENDENCY react@^0.14.0
  ├── UNMET PEER DEPENDENCY react-dom@^0.14.0
  └── [email protected] 
  1. 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(…)

yarnball avatar Nov 16 '16 02:11 yarnball

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

bmulcahy avatar Feb 17 '17 14:02 bmulcahy

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.

JeremyIglehart avatar Apr 14 '17 11:04 JeremyIglehart

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

lukasborawski avatar Oct 09 '17 15:10 lukasborawski

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.

aviemet avatar Jan 09 '19 23:01 aviemet

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

is-prashant avatar Jan 27 '19 14:01 is-prashant

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
/>

jnsandrew avatar Apr 01 '19 16:04 jnsandrew