Simple Calendar using ReactJS & MomentJS
Making a simple full year dynamic calendar using Reactjs and Momentjs
MomentJS is a JavaScript library which helps is parsing, validating, manipulating and displaying date/time in JavaScript. Using this library we can easily make a simple dynamic full year calendar in ReactJS.
Step 1 : First of all lets create a ReactJS project using the command
npx create-react-app Calendar (using your terminal in your desired folder)
Step 2 : Install momentjS inside project terminal
npm i moment (link)
Step 3 : create a functional component and import moment from moments
Step 4 : Lets save all the months from momentJS to a variable and also get the year.
Step 5: Lets write a function to get all days from a month with week basis.
Step 6: Lets map all the months and calender to the table
We are passing the months as the index value. 0 as jan … 11 as dec.. to our getDate() calendar function
Check out the complete program at my codesandbox.io