Problems using React Datepicker with rails

I am using this datepicker plugin for react: https://github.com/Hacker0x01/react-datepicker

I keep getting the following error: Uncaught TypeError: this.props.moment is not a function in response-datepicker.min.js.

I just copied the example code and I can see the input field, but whenever I click on it to render the calendar it keeps giving the error above. Did anyone know if this question was in the past?

+3


source to share


1 answer


Just resolved it, it was not a requirement for a "js file of the moment" in application.js. If you are using bundler to install this plugin, be sure to add the following to your gemfile:

source "https://rails-assets.org" do
  gem 'rails-assets-react-date-picker'
  gem "rails-assets-moment"
end

      



and then require as in application.js in the following order:

//= require "moment"
//= require "react-date-picker"

      

+3


source







All Articles