-1

I'm trying to tweak this module called react-add-to-calendar to support onClick events when clicking the dropdown items since the creator of the library seems to be not maintaining it anymore. I've moved the ReactAddToCalendar.js file over to my project and require it like this:

import AddToCalendar from 'apps/bookings/components/ReactAddToCalendar'

And also have a ReactAddToCalendar.d.ts that looks like this according to this answer:

declare module "ReactAddToCalendar";

But now I'm getting this error:

File '.../{project_name}/app/javascript/apps/bookings/components/ReactAddToCalendar.d.ts' is not a module.

I've tried looking everywhere on how to get over this but I can't find anything.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ccyan
  • 1,057
  • 12
  • 32

1 Answers1

0

You have to install it like this from your command line:

npm install react-add-to-calendar --save

and then you only have to put this in the desired component:

import AddToCalendar from 'react-add-to-calendar';

Example from the git of the component:

import React from 'react';
import AddToCalendar from 'react-add-to-calendar';

class Example extends React.Component {
  static displayName = 'Example';
  state = {
    event: {
      title: 'Sample Event',
      description: 'This is the sample event provided as an example only',
      location: 'Portland, OR',
      startTime: '2016-09-16T20:15:00-04:00',
      endTime: '2016-09-16T21:45:00-04:00'
    }
  };

  render() {
    return <AddToCalendar event={this.state.event}/>;
  };
}

the instructions are right over there. Or you cant install the modules from NPM?

  • It doesn't have a piece of functionality that I need, so I tried to move it over to my own project and tweak it. I just can't seem to require it now. – Ccyan Jun 17 '20 at 18:04
  • 1
    Oh, ok, i understant it now. Maybe you can download all the package from github, edit it as you need, and then publish the package to npm as private (its really easy! just two commands) so you can use it as you please – Sebastian Cristi Castillo Jun 17 '20 at 18:07
  • Ah, can you point me to a tutorial for that? I'm pretty new to all this so I'm still trying to find my way. Thank you! – Ccyan Jun 17 '20 at 18:21