UPDATE: (This post is only relevant if you’re using the react-datepicker npm package)
It turns out that it was the props to a totally different package react-datepicker that was causing this issue.
By changing my input to the following, it works.
Project = React.createClass({
getInitialState: function () {
return {
submissionDate:moment() //<-- removed the .format()
}
},
render() {
<DatePicker selected={this.state.submissionDate} />
}
Original
I must be losing my mind…
With the following code
Project = React.createClass({
getInitialState: function () {
return {
submissionDate:moment().format(), //<--- this is the culprit
}
},
I get Uncaught: TypeError: t.format is not a function
(how do I tell Meteor to not minify app.browserify.js?):
This is fine, no errors
Project = React.createClass({
getInitialState: function () {
var now = moment().format();
console.log("Now: " + now);
return {
submissionDate: "I'm happy"
}
}
But the moment I try to set the state, I get the t.format
error in app.browserify:
Project = React.createClass({
getInitialState: function () {
var now = moment().format();
console.log("Now: " + now);
return {
submissionDate: now
}
},
componentDidMount() {
this.setState({submissionDate: moment().format()})
}
Relevant files:
// client/lib/app.browserfiy.js
DatePicker = require("react-datepicker");
Video = require('react-video');
Vimeo = require('react-vimeo');
Youtube = require('react-youtube');
moment = require('moment');
// packages.json
{
"react-datepicker":"0.12.0",
"react-video":"1.5.3",
"react-vimeo":"0.0.3",
"externalify":"0.1.0",
"react-youtube":"4.1.0",
"moment":"2.10.6"
}