An easy hook to use with expo-calendar library!

Overview

useCalendar Hook 🚀 useCalendar version

made with expo

Updated to Expo SDK45

This is an easy hook to use expo-calendar. It allows you:

  • Get access permission to calendar
  • Open settings to give access permission to calendar
  • Create a new calendar and store it on your device
  • Add events to the calendar
  • Check if an event exists inside of the calendar created
  • Delete the calendar and all events inside of it

Install

$ npm install @atiladev/usecalendar
or
$ yarn add @atiladev/usecalendar

How to use it

Start by importing the useCalendar hook and then import the packages that you need to interact with the Calendar:

import useCalendar from '@atiladev/usecalendar';

const {
  getPermission,
  createCalendar,
  addEventsToCalendar,
  deleteCalendar,
  openSettings,
  isThereEvents,
} = useCalendar('App_Name', '#BADA55', 'Calendar_Name');

const createCalAndEvent = async () => {
  const granted = await getPermission();

  if (granted) {
    await createCalendar();
    let eventExists = await isThereEvents();

    if (!eventExists) {
      try {
        addEventsToCalendar('Event title', new Date(), new Date());
      } catch (e) {
        // Something went wrong
      }
    }
  } else {
    openSettings();
  }
};

const RemoveCalendar = () => deleteCalendar();

useCalendar

useCalendar(title: string, color: string, storeName: string);

useCalendar returns:

getPermission: () => Promise<Calendar[] | undefined>

createCalendar: () => Promise<void>

addEventsToCalendar: (eventTitle: string, eventStartDate: Date, eventEndDate: Date) => Promise<void>

deleteCalendar: () => Promise<void>

openSettings: () => Promise<void>

isThereEvents: () => Promise<boolean>

If this hook is useful for you, please consider giving it a star. This does not mean very much but motivates us to continue working on this and adding new features. Thanks!

Developed with ❤️ by Leandro Favre (AtilaDev)

You might also like...

A lite version for the my original app loki stream which allowed watching anime on your phone. Made using expo.

A lite version for the my original app loki stream which allowed watching anime on your phone. Made using expo.

LokiStream Lite A lite version for the my original app loki stream. This app is faster, smaller and more optimized for your phone. It allows you to wa

Dec 24, 2022

Expo Demo: Screen Capture with Managed Workflow

Expo Demo: Screen Capture with Managed Workflow This code demonstrates how to setup screen capture on an Expo app, without having to eject from the ma

Dec 30, 2022

A new renovated version of Directory to search @expo-google-fonts

Directory | AtilaDev Directory is an easy & quick search to find google fonts using @expo-google-fonts for your React Native App. Usage Press / key to

Oct 5, 2022

ESLint plugin for react-hook-form

eslint-plugin-react-hook-form react-hook-form is an awsome library which provide a neat solution for building forms. However, there are many rules for

Nov 22, 2022

An extremely helpful React Hook to trap the focusable elements / Hello Modals! Hello a11y!

react-use-focus-trap Everytime when people implement Modals... ...People forget that pro users as well as users that are permanently or temporarily re

Nov 30, 2022

This hook allows you to isolate and manage the state within the component, reducing rendering operations and keeping the source code concise.

React Hook Component State This hook allows you to isolate and manage the state within the component, reducing rendering operations and keeping the so

May 15, 2022

A hook based project created during 20-Dec week ReactJS workshop

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Dec 25, 2021

Small (0.5 Kb) react hook for getting media breakpoints state info in runtime

tiny-use-media Small (0.5 Kb) react hook for getting media breakpoints state info in runtime Usage npm i tiny-use-media --save Adn in your react code

Dec 13, 2022

A reusable react hook that preserves a components semantic accessibility to create a visual block link.

A reusable react hook that preserves a components semantic accessibility to create a visual block link.

useAccessibleBlockLink is a reusable react hook that preserves a components semantic accessibility to create a visual block link. This hook supports multiple links within the same block.

Nov 28, 2022
Comments
  • Write a tutorial/blog post on how to use it

    Write a tutorial/blog post on how to use it

    Todo:

    • Write a blog post/tutorial on how to use this hook with expo-calendar library.
    • You can ask Expo folks to publish it on blog.expo.dev
    • After the blog post is published, add the link to the repo -> Readme.md file
    documentation 
    opened by amandeepmittal 2
Expo Config Plugin that generates an App Clip for iOS apps built with Expo.

react-native-app-clip Expo Config Plugin that generates an App Clip for iOS apps built with Expo. Warning This plugin is a work in progress and hasn’t

Benedikt 186 Dec 24, 2022
React hook library, ready to use, written in Typescript.

usehooks-ts React hook library, ready to use, written in Typescript. npm i usehooks-ts Created by Julien Caron and maintained with ❤️ by an amazing te

Julien 2.8k Jan 5, 2023
react-dialog is a custom react hook to use a dialog easily

react-dialog react-dialog is a custom react hook to use a dialog easily. Documentation To use react-dialog follow the documentation. useDialog Returns

Levy Mateus Macedo 2 Mar 29, 2022
A custom react hook to use a dialogs easily.

dialog-hook The dialog-hook is a custom react hook to use a dialog easily. First of all it is necessary to install the package in your project some co

Levy Mateus Macedo 2 Mar 29, 2022
Boilerplate to build Cross-Platform Apps with Expo and React Native

Expo and React Native Boilerplate Boilerplate to build Cross-Platform Apps with Expo and React Native What are you going to find in this boilerplate E

José Ferrer 26 Apr 29, 2022
React Native & Expo music player application UI

Would you like to support me? Musicont React Native & Expo music player application UI Demo: https://expo.io/@jsxclan/musicont APK: Download on Google

JSX Clan 82 Dec 14, 2022
Our Expo-based mobile application for demonstration purposes.

Capable Care reference implementation This repository provides a working example of a React Native mobile application (built on Expo) integrating Capa

Capable Health 11 Oct 1, 2022
A simple example on how to get WalletConnect to authenticate wallets in the Expo Go app.

WalletConnect Example on Expo This is a simple example how to get WalletConnect up and running with Expo for React Native. WalletConnect's dependency

Carlos A. Wong 60 Dec 30, 2022
Tamagui with Supabase, Expo, Next.js, Solito and Jotai

Tamagui + Supabase + Solito + Next + Expo Monorepo ⚡️ Instant clone & deploy ?? About This monorepo is a starter todo app, built using Supabase + Expo

Lachlan Hawthorne 15 Dec 12, 2022
Convert a CSS linear gradient function to expo-linear-gradient props

@bacons/css-to-expo-linear-gradient Demo: snack Convert a CSS linear gradient function to expo-linear-gradient props. Add the package to your npm depe

Evan Bacon 15 Dec 15, 2022