0

Is there any idea how to add fullcalendar to SPFx react functional component?

I need to add the below fullcalendar component in my SPFx react solution.

https://fullcalendar.io/docs/react

I have found the below link but it is for the class component.

https://github.com/garima2510/SPFx-React-FullCalendar-Panel

Can anyone suggest to me fullcalendar for SPFx React Class Component?

I have imported the Font Awesome library in SPFx React Class Component Solution and It is working correctly. I have used the below link as a reference,

https://sharepoint.stackexchange.com/questions/297690/adding-external-css-fontawesome-to-an-spfx-webpart-on-spo

Now, I need to add Font Awesome library in SPFx React Functional Component Solution without using any npm packages.

I have imported the font-family in my SPFx react solution. Below is the code snippet for the same.

@font-face {
    font-family: 'Work Sans Regular';
    font-style: normal;
    font-weight: normal;
    src: local('Work Sans Regular'), url('../fonts/WorkSans-Regular.woff2') format('woff2');
}

.root-div {
    font-family: 'Work Sans Regular' !important;
}

I am facing the above error after adding font family in my solution. enter image description here

Can anyone help me with the above points?

Thanks

2
  • Check this web part sample which uses full calendar library: github.com/pnp/sp-dev-fx-webparts/tree/main/samples/…. Let me know if this works for you. Commented Sep 17, 2022 at 14:03
  • @Ganesh Thanks for your response. I have created an SPFx solution with React. So, I will need a calendar that works correctly under the .tsx file. Can you please share your thoughts on the same? Commented Sep 19, 2022 at 12:58

2 Answers 2

1

For font-aweseome: It is almost the same in functional components. But since there is no constructor you can use the useEffect hook.

import * as React from 'react';
import { SPComponentLoader } from "@microsoft/sp-loader";

const SimpleComponent:React.FC<{}> = () => {

    React.useEffect(() => {
        SPComponentLoader.loadCss("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css");
    },[]);

    return (
        <div>
            <i className="fa fa-edit"></i>
        </div>
    );
};

export { SimpleComponent };

Results in

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

I have found the solution. I have used the full-calendar component.

Please install the below packages.

Please refer to below code snippet,

import FullCalendar, { EventInput, EventApi, DateSelectArg, EventClickArg, EventContentArg, formatDate } from '@fullcalendar/react';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction';

<FullCalendar
       plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin]}
       headerToolbar={{
              left: 'prev,next today',
              center: 'title',
              right: 'dayGridMonth,timeGridWeek,timeGridDay'
       }}
       initialView='dayGridMonth'
       editable={false}
       selectable={false}
       selectMirror={false}
       dayMaxEvents={false}
       initialEvents={allEvents}
       events={allEvents}
/>

Please refer to the below link for more details,

https://fullcalendar.io/docs/getting-started

Thanks

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.