Top 7 React 달력 The 145 New Answer

You are looking for information, articles, knowledge about the topic nail salons open on sunday near me react 달력 on Google, you do not find the information you need! Here are the best content compiled and compiled by the https://chewathai27.com/to team, along with other related topics such as: react 달력 React 달력 만들기, React 달력 라이브러리, React-datepicker, React-big calendar 사용법, React-google calendar, 리액트 달력 만들기, react-big-calendar, React-calendar TypeScript


React가 포함된 Google 캘린더 클론 – React Hooks, React Context 및 Tailwind
React가 포함된 Google 캘린더 클론 – React Hooks, React Context 및 Tailwind


react-calendar – npm

  • Article author: www.npmjs.com
  • Reviews from users: 34001 ⭐ Ratings
  • Top rated: 3.5 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about react-calendar – npm Ultimate calendar for your React app.. Latest version: 3.7.0, last published: 6 months ago. Start using react-calendar in your project by … …
  • Most searched keywords: Whether you are looking for react-calendar – npm Ultimate calendar for your React app.. Latest version: 3.7.0, last published: 6 months ago. Start using react-calendar in your project by … Ultimate calendar for your React app.. Latest version: 3.7.0, last published: 6 months ago. Start using react-calendar in your project by running `npm i react-calendar`. There are 298 other projects in the npm registry using react-calendar.calendar,date,date-picker,month-picker,react
  • Table of Contents:

react-calendar

tl;dr

Demo

Before you continue

Getting started

User guide

Useful links

License

Author

Thank you

Keywords

react-calendar - npm
react-calendar – npm

Read More

(React) 리액트 달력만들기 (초간단/쉬움)

  • Article author: eunhee-programming.tistory.com
  • Reviews from users: 13503 ⭐ Ratings
  • Top rated: 3.7 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about (React) 리액트 달력만들기 (초간단/쉬움) (React) 리액트 달력만들기 (초간단/쉬움) · 1. 결과화면(사진 및 동영상) · 2. 파일 구조 · 3. 코드 · 4. 깃허브 코드 주소 … …
  • Most searched keywords: Whether you are looking for (React) 리액트 달력만들기 (초간단/쉬움) (React) 리액트 달력만들기 (초간단/쉬움) · 1. 결과화면(사진 및 동영상) · 2. 파일 구조 · 3. 코드 · 4. 깃허브 코드 주소 … * 본 포스팅은 직접 구현한 코드입니다. * 불펌 금지합니다. * 더 좋은 코드가 있으면 가르쳐주세요 감사합니다 🙂 포스팅 요약 1. 결과화면(사진 및 동영상) 2. 파일 구조 3. 코드 4. 깃허브 코드 주소 1. 결과화..
  • Table of Contents:

태그

관련글

댓글0

공지사항

최근글

인기글

최근댓글

전체 방문자

티스토리툴바

(React) 리액트 달력만들기 (초간단/쉬움)
(React) 리액트 달력만들기 (초간단/쉬움)

Read More

[리액트] react-calendar로 캘린더 제작: 하이라이트 기능

  • Article author: breathtaking-life.tistory.com
  • Reviews from users: 3893 ⭐ Ratings
  • Top rated: 3.5 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about [리액트] react-calendar로 캘린더 제작: 하이라이트 기능 react-calendar 라이브러리 설치. 2.2. -코드 작성. 2.3. -css로 꾸미기. 3. – 하이라이트 기능 추가. 3.1. – CSS 코드. 3.2. – 날짜 지정. …
  • Most searched keywords: Whether you are looking for [리액트] react-calendar로 캘린더 제작: 하이라이트 기능 react-calendar 라이브러리 설치. 2.2. -코드 작성. 2.3. -css로 꾸미기. 3. – 하이라이트 기능 추가. 3.1. – CSS 코드. 3.2. – 날짜 지정. – 결과 현재 제작하고 있는 건 다이어리 웹이다. 언제 일기를 작성했는지 보여준다. 위 사진은 2022년 1월 3, 7, 12, 13, 15일에 작성하였다고 보여주는 예시이다. 작성 날짜들을 표시할 수 있게 하이라이트 기능..Fake it till you make it.
  • Table of Contents:

– 결과

– 초기 설정

– 하이라이트 기능 추가

티스토리툴바

[리액트] react-calendar로 캘린더 제작: 하이라이트 기능
[리액트] react-calendar로 캘린더 제작: 하이라이트 기능

Read More

Calendar – React.js Examples

  • Article author: reactjsexample.com
  • Reviews from users: 40760 ⭐ Ratings
  • Top rated: 3.9 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about Calendar – React.js Examples Calendar ; Airbnb date picker built with react. 06 June 2022 ; Build and Deploy a React Admin Dashboard App With Theming, Tables, Charts, Calendar, Kanban … …
  • Most searched keywords: Whether you are looking for Calendar – React.js Examples Calendar ; Airbnb date picker built with react. 06 June 2022 ; Build and Deploy a React Admin Dashboard App With Theming, Tables, Charts, Calendar, Kanban …
  • Table of Contents:

A collection of 102 posts

Airbnb style date picker built with react

A React Admin Dashboard App With Theming Tables Charts Calendar Kanban and More

Datepicker library based for Reactjs

Create a demo calendar application using React

Calendar built in react together with the date-fns library

Calendar interval time picker and popup components for React supports multi-languages

A react contribution heatmap calendar component

React date picker Made with create-react-library

A Simple Calendar App Built Using Reactjs

Family Bingo a ultra lightweight simple Christmas-themed bingo display written in React

A calendar timetable for react native

Highly customizable atomic components for React calendar date pickers

React calendar component with support for multiple views and events

A simple year range picker component for React

Beautiful minimal and accessible date-picker for React

A simple react datepicker component build with date-fns and Chakra-UI

A convenient JavaScript snippet which lets you create beautiful buttons where people can add events to their calendars

Community events from TwitterSpaces to Live streams to Conferences

A React Calendar App That Helps Students Manage Their Deadlines And Events On Moodle

A headless calendar hook for React

Official React wrapper for the year-calendar widget

A React component to display a GitHub contributions graph based on react-activity-calendar

A simple React Calendar component

An official React component for FullCalendar

A lightweight and feature-rich calendar component for react

A React component to display activity data in a calendar heatmap

Calendso Open-Source Calendly alternativeFull control of your events and data

A customizable calendar heatmap react component built on SVG

A React application for managing events and meetings

Simple and flexible events calendar written in React

React Calendar Component that displays data from Google Calendar

A DateRange picker for ReactJS

DatePicker could be created in few hours with react

A lightweight nepali datepicker for reactjs

A simple calendar where you can add reminders for a specific datetime and city

A React library to help compose a Date PickerCalendar around your components

A responsive and modular date picker library for React

A simple calendar component for React based applications

A React component for persian date and time input

Calendar based nisualization of one kind of activity

Every Day Calendar With React

An easily internationalizable and mobile-friendly datepicker library for the web

A React daterange picker for Tripema

A small package for adding an event to a calendar

A lightweight and Persian date picker for React

A decent and pretty date picker to be used with ReactJS

A lightweight calendar for React

A simple datepicker component for React with persian jalaali calendar

A simple datepicker component for React with persian jalaali calendar

Advance React Date and Time Picker for jalaali calender

Calendar - React.js Examples
Calendar – React.js Examples

Read More

10 Best React Calendar Libraries in 2022 | Openbase

  • Article author: openbase.com
  • Reviews from users: 41505 ⭐ Ratings
  • Top rated: 4.8 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about 10 Best React Calendar Libraries in 2022 | Openbase List hand-picked by Openbase Experts. Learn More · react-calendar · react-big-calendar · @fullcalendar/react · react-calendar-timeline · expo-calendar · @nivo/ … …
  • Most searched keywords: Whether you are looking for 10 Best React Calendar Libraries in 2022 | Openbase List hand-picked by Openbase Experts. Learn More · react-calendar · react-big-calendar · @fullcalendar/react · react-calendar-timeline · expo-calendar · @nivo/ … A comparison of the 10 Best React Calendar Libraries in 2022: @progress/kendo-react-dateinputs, @syncfusion/ej2-react-calendars, @fullcalendar/react, react-calendar-timeline, gantt-schedule-timeline-calendar and more
  • Table of Contents:

List hand-picked by Openbase ExpertsLearn More

react-calendar

react-big-calendar

@fullcalendarreact

10 Best React Calendar Libraries in 2022 | Openbase
10 Best React Calendar Libraries in 2022 | Openbase

Read More

[React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리) — 용뇽 개발 노트

  • Article author: yong-nyong.tistory.com
  • Reviews from users: 44689 ⭐ Ratings
  • Top rated: 4.4 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about [React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리) — 용뇽 개발 노트 [React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리). 들어가며. 이번에 팀 프로젝트로 팀 프로젝트를 구하는 웹앱을 클론 … …
  • Most searched keywords: Whether you are looking for [React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리) — 용뇽 개발 노트 [React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리). 들어가며. 이번에 팀 프로젝트로 팀 프로젝트를 구하는 웹앱을 클론 … 📖 들어가며 이번에 팀 프로젝트로 팀 프로젝트를 구하는 웹앱을 클론 코딩하게 되면서 프로젝트 진행 기간을 선택할 수 있게 하는 Input이 필요했습니다. 그래서 캘린더가 표시되고 캘린더에서 날짜를 선택하면..
  • Table of Contents:

블로그 메뉴

공지사항

인기 글

태그

최근 댓글

최근 글

티스토리

📖 들어가며

1 react-datepicker

2 설치

3 사용하기

4 커스텀

5 최종 결과

📕 마무리

티스토리툴바

[React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리) — 용뇽 개발 노트
[React] react-datepicker 라이브러리 사용 하기(캘린더, 달력 라이브러리) — 용뇽 개발 노트

Read More

GitHub – wojtekmaj/react-calendar: Ultimate calendar for your React app.

  • Article author: github.com
  • Reviews from users: 37485 ⭐ Ratings
  • Top rated: 3.0 ⭐
  • Lowest rated: 1 ⭐
  • Summary of article content: Articles about GitHub – wojtekmaj/react-calendar: Ultimate calendar for your React app. Updating …
  • Most searched keywords: Whether you are looking for GitHub – wojtekmaj/react-calendar: Ultimate calendar for your React app. Updating Ultimate calendar for your React app. Contribute to wojtekmaj/react-calendar development by creating an account on GitHub.
  • Table of Contents:

Latest commit

Git stats

Files

READMEmd

tl;dr

Demo

Before you continue

Getting started

User guide

Useful links

License

Author

Thank you

About

Releases
76

Sponsor this project

Packages 0

Used by 328k

Contributors 34

Languages

Footer

GitHub - wojtekmaj/react-calendar: Ultimate calendar for your React app.
GitHub – wojtekmaj/react-calendar: Ultimate calendar for your React app.

Read More


See more articles in the same category here: Chewathai27.com/to/blog.

react-calendar

Ultimate calendar for your React app.

Pick days, months, years, or even decades

Supports range selection

Supports virtually any language

No moment.js needed

Install by executing npm install react-calendar or yarn add react-calendar .

or . Import by adding import Calendar from ‘react-calendar’ .

. Use by adding . Use onChange prop for getting new values.

Demo

A minimal demo page can be found in sample directory.

Online demo is also available!

Before you continue

React-Calendar is under constant development. This documentation is written for React-Calendar 3.x branch. If you want to see documentation for other versions of React-Calendar, use dropdown on top of GitHub page to switch to an appropriate tag. Here are quick links to the newest docs from each branch:

Getting started

Compatibility

Your project needs to use React 16.3 or later.

React-Calendar uses modern web technologies. That’s why it’s so fast, lightweight and easy to style. This, however, comes at a cost of supporting only modern browsers.

Legacy browsers

If you need to support legacy browsers like Internet Explorer 10, you will need to use Intl.js or another Intl polyfill along with React-Calendar.

Installation

Add React-Calendar to your project by executing npm install react-calendar or yarn add react-calendar .

Usage

Here’s an example of basic usage:

import React , { useState } from ‘react’ ; import Calendar from ‘react-calendar’ ; function MyApp ( ) { const [ value , onChange ] = useState ( new Date ( ) ) ; return ( < div > < Calendar onChange = { onChange } value = { value } / > < / div > ) ; }

Check the sample directory in this repository for a full working example. For more examples and more advanced use cases, check Recipes in React-Calendar Wiki.

Custom styling

If you want to use default React-Calendar styling to build upon it, you can import React-Calendar’s styles by using:

import ‘react-calendar/dist/Calendar.css’ ;

User guide

Calendar

Displays a complete, interactive calendar.

Props

Prop name Description Default value Example values activeStartDate The beginning of a period that shall be displayed. If you wish to use React-Calendar in an uncontrolled way, use defaultActiveStartDate instead. (today) new Date(2017, 0, 1) allowPartialRange Whether to call onChange with only partial result given selectRange prop. false true calendarType Type of calendar that should be used. Can be “ISO 8601” , “US” , “Arabic” , or “Hebrew” . Setting to “US” or “Hebrew” will change the first day of the week to Sunday. Setting to “Arabic” will change the first day of the week to Saturday. Setting to “Arabic” or “Hebrew” will make weekends appear on Friday to Saturday. Type of calendar most commonly used in a given locale “ISO 8601” className Class name(s) that will be added along with “react-calendar” to the main React-Calendar

element. n/a String: “class1 class2”

Array of strings: [“class1”, “class2 class3”] defaultActiveStartDate The beginning of a period that shall be displayed by default. If you wish to use React-Calendar in a controlled way, use activeStartDate instead. (today) new Date(2017, 0, 1) defaultValue Calendar value that shall be selected initially. Can be either one value or an array of two values. If you wish to use React-Calendar in a controlled way, use value instead. n/a Date: new Date()

An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)] defaultView Determines which calendar view shall be opened initially. Does not disable navigation. Can be “month” , “year” , “decade” or “century” . If you wish to use React-Calendar in a controlled way, use view instead. The most detailed view allowed “year” formatDay Function called to override default formatting of day tile labels. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘d’) formatLongDate Function called to override default formatting of day tile abbr labels. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘dd MMM YYYY’) formatMonth Function called to override default formatting of month names. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘MMM’) formatMonthYear Function called to override default formatting of months and years. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘MMMM YYYY’) formatShortWeekday Function called to override default formatting of weekday names. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘dd’) formatYear Function called to override default formatting of year in the top navigation section. Can be used to use your own formatting function. (default formatter) (locale, date) => formatDate(date, ‘YYYY’) inputRef A prop that behaves like ref, but it’s passed to main

rendered by component. n/a Function:

(ref) => { this.myCalendar = ref; }

Ref created using React.createRef :

this.ref = React.createRef();

inputRef={this.ref}

: … Ref created using React.useRef :

const ref = React.useRef();

inputRef={ref} locale Locale that should be used by the calendar. Can be any IETF language tag. User’s browser settings “hu-HU” maxDate Maximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although React-Calendar will ensure that no later date is selected. n/a Date: new Date() maxDetail The most detailed view that the user shall see. View defined here also becomes the one on which clicking an item will select a date and pass it to onChange. Can be “month” , “year” , “decade” or “century” . “month” “year” minDate Minimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although React-Calendar will ensure that no earlier date is selected. n/a Date: new Date() minDetail The least detailed view that the user shall see. Can be “month” , “year” , “decade” or “century” . “century” “decade” navigationAriaLabel aria-label attribute of a label rendered on calendar navigation bar. n/a “Go up” navigationAriaLive aria-live attribute of a label rendered on calendar navigation bar. undefined “polite” navigationLabel Content of a label rendered on calendar navigation bar. (default label) ({ date, label, locale, view }) => `Current view: ${view}, date: ${date.toLocaleDateString(locale)}` nextAriaLabel aria-label attribute of the “next” button on the navigation pane. n/a “Next” nextLabel Content of the “next” button on the navigation pane. Setting the value explicitly to null will hide the icon. “›” String: “›”

React element: next2AriaLabel aria-label attribute of the “next on higher level” button on the navigation pane. n/a “Jump forwards” next2Label Content of the “next on higher level” button on the navigation pane. Setting the value explicitly to null will hide the icon. “»” String: “»”

React element: onActiveStartDateChange Function called when the user navigates from one view to another using previous/next button. Note that this function will not be called when e.g. drilling up from January 2021 to 2021 or drilling down the other way around.

action signifies the reason for active start date change and can be one of the following values: “prev” , “prev2” , “next” , “next2” , “drillUp” , “drillDown” , “onChange” . n/a ({ action, activeStartDate, value, view }) => alert(‘Changed view to: ‘, activeStartDate, view) onChange Function called when the user clicks an item (day on month view, month on year view and so on) on the most detailed view available. n/a (value, event) => alert(‘New date is: ‘, value) onViewChange Function called when the user navigates from one view to another using drill up button or by clicking a tile.

action signifies the reason for view change and can be one of the following values: “prev” , “prev2” , “next” , “next2” , “drillUp” , “drillDown” , “onChange” . n/a ({ action, activeStartDate, value, view }) => alert(‘New view is: ‘, view) onClickDay Function called when the user clicks a day. n/a (value, event) => alert(‘Clicked day: ‘, value) onClickDecade Function called when the user clicks a decade. n/a (value, event) => alert(‘Clicked decade: ‘, value) onClickMonth Function called when the user clicks a month. n/a (value, event) => alert(‘Clicked month: ‘, value) onClickWeekNumber Function called when the user clicks a week number. n/a (weekNumber, date, event) => alert(‘Clicked week: ‘, weekNumber, ‘that starts on: ‘, date) onClickYear Function called when the user clicks a year. n/a (value, event) => alert(‘Clicked year: ‘, value) onDrillDown Function called when the user drills down by clicking a tile. n/a ({ activeStartDate, view }) => alert(‘Drilled down to: ‘, activeStartDate, view) onDrillUp Function called when the user drills up by clicking drill up button. n/a ({ activeStartDate, view }) => alert(‘Drilled up to: ‘, activeStartDate, view) prevAriaLabel aria-label attribute of the “previous” button on the navigation pane. n/a “Previous” prevLabel Content of the “previous” button on the navigation pane. Setting the value explicitly to null will hide the icon. “‹” String: “‹”

React element: prev2AriaLabel aria-label attribute of the “previous on higher level” button on the navigation pane. n/a “Jump backwards” prev2Label Content of the “previous on higher level” button on the navigation pane. Setting the value explicitly to null will hide the icon. “«” String: “«”

React element: returnValue Which dates shall be passed by the calendar to the onChange function and onClick{Period} functions. Can be “start” , “end” or “range” . The latter will cause an array with start and end values to be passed. “start” “range” showDoubleView Whether to show two months/years/… at a time instead of one. Defaults showFixedNumberOfWeeks prop to be true . false true showFixedNumberOfWeeks Whether to always show fixed number of weeks (6). Forces showNeighboringMonth prop to be true . false true showNavigation Whether a navigation bar with arrows and title shall be rendered. true false showNeighboringMonth Whether days from previous or next month shall be rendered if the month doesn’t start on the first day of the week or doesn’t end on the last day of the week, respectively. true false selectRange Whether the user shall select two dates forming a range instead of just one. Note: This feature will make React-Calendar return array with two dates regardless of returnValue setting. false true showWeekNumbers Whether week numbers shall be shown at the left of MonthView or not. false true tileClassName Class name(s) that will be applied to a given calendar item (day on month view, month on year view and so on). n/a String: “class1 class2”

Array of strings: [“class1”, “class2 class3”]

Function: ({ activeStartDate, date, view }) => view === ‘month’ && date.getDay() === 3 ? ‘wednesday’ : null tileContent Allows to render custom content within a given calendar item (day on month view, month on year view and so on). n/a String: “Sample”

React element:

Function: ({ activeStartDate, date, view }) => view === ‘month’ && date.getDay() === 0 ?

It’s Sunday!

: null tileDisabled Pass a function to determine if a certain day should be displayed as disabled. n/a Function: ({activeStartDate, date, view }) => date.getDay() === 0 value Calendar value. Can be either one value or an array of two values. If you wish to use React-Calendar in an uncontrolled way, use defaultValue instead. n/a Date: new Date()

An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)] view Determines which calendar view shall be opened. Does not disable navigation. Can be “month” , “year” , “decade” or “century” . If you wish to use React-Calendar in an uncontrolled way, use defaultView instead. The most detailed view allowed “year”

MonthView, YearView, DecadeView, CenturyView

Displays a given month, year, decade and a century, respectively.

Props

Prop name Description Default value Example values activeStartDate The beginning of a period that shall be displayed. n/a new Date(2017, 0, 1) hover The date over which the user is hovering. Used only when selectRange is enabled, to render a “WIP” range when the user is selecting range. n/a new Date(2017, 0, 1) maxDate Maximum date that the user can select. Periods partially overlapped by maxDate will also be selectable, although react-calendar will ensure that no later date is selected. n/a Date: new Date() minDate Minimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although react-calendar will ensure that no earlier date is selected. n/a Date: new Date() onClick Function called when the user clicks an item (day on month view, month on year view and so on). n/a (value) => alert(‘New date is: ‘, value) tileClassName Class name(s) that will be applied to a given calendar item (day on month view, month on year view and so on). n/a String: “class1 class2”

Array of strings: [“class1”, “class2 class3”]

Function: ({ date, view }) => view === ‘month’ && date.getDay() === 3 ? ‘saturday’ : null tileContent Allows to render custom content within a given item (day on month view, month on year view and so on). Note: For tiles with custom content you might want to set fixed height of react-calendar__tile to ensure consistent layout. n/a ({ date, view }) => view === ‘month’ && date.getDay() === 0 ?

It’s Sunday!

: null value Calendar value. Can be either one value or an array of two values. n/a Date: new Date()

An array of dates: [new Date(2017, 0, 1), new Date(2017, 7, 1)]

String: 2017-01-01

An array of strings: [‘2017-01-01’, ‘2017-08-01’]

Useful links

License

The MIT License.

Author

Thank you

Sponsors

Thank you to all our sponsors! Become a sponsor and get your image on our README on GitHub.

Backers

Thank you to all our backers! Become a backer and get your image on our README on GitHub.

Top Contributors

Thank you to all our contributors that helped on this project!

(React) 리액트 달력만들기 (초간단/쉬움)

반응형

* 본 포스팅은 직접 구현한 코드입니다.

* 불펌 금지합니다.

* 더 좋은 코드가 있으면 가르쳐주세요 감사합니다 🙂

포스팅 요약

1. 결과화면(사진 및 동영상)

2. 파일 구조

3. 코드

4. 깃허브 코드 주소

1. 결과화면 (사진 및 동영상)

1) 사진

2) 동영상

2. 파일 구조

3. 코드

경로: public/index.html

달력

경로: src/App.js

import Calendar from “./component/Calendar”; function App() { return (

); } export default App;

경로: src/component/Calendar.js

import React, { useCallback, useState } from “react”; import classNames from “classnames/bind”; import style from “../style/calendar.css”; const cx = classNames.bind(style); const Calendar = () => { const today = { year: new Date().getFullYear(), //오늘 연도 month: new Date().getMonth() + 1, //오늘 월 date: new Date().getDate(), //오늘 날짜 day: new Date().getDay(), //오늘 요일 }; const week = [“일”, “월”, “화”, “수”, “목”, “금”, “토”]; //일주일 const [selectedYear, setSelectedYear] = useState(today.year); //현재 선택된 연도 const [selectedMonth, setSelectedMonth] = useState(today.month); //현재 선택된 달 const dateTotalCount = new Date(selectedYear, selectedMonth, 0).getDate(); //선택된 연도, 달의 마지막 날짜 const prevMonth = useCallback(() => { //이전 달 보기 보튼 if (selectedMonth === 1) { setSelectedMonth(12); setSelectedYear(selectedYear – 1); } else { setSelectedMonth(selectedMonth – 1); } }, [selectedMonth]); const nextMonth = useCallback(() => { //다음 달 보기 버튼 if (selectedMonth === 12) { setSelectedMonth(1); setSelectedYear(selectedYear + 1); } else { setSelectedMonth(selectedMonth + 1); } }, [selectedMonth]); const monthControl = useCallback(() => { //달 선택박스에서 고르기 let monthArr = []; for (let i = 0; i < 12; i++) { monthArr.push(); } return ( ); }, [selectedMonth]); const yearControl = useCallback(() => { //연도 선택박스에서 고르기 let yearArr = []; const startYear = today.year – 10; //현재 년도부터 10년전 까지만 const endYear = today.year + 10; //현재 년도부터 10년후 까지만 for (let i = startYear; i < endYear + 1; i++) { yearArr.push(); } return ( ); }, [selectedYear]); const changeSelectMonth = (e) => { setSelectedMonth(Number(e.target.value)); }; const changeSelectYear = (e) => { setSelectedYear(Number(e.target.value)); }; const returnWeek = useCallback(() => { //요일 반환 함수 let weekArr = []; week.forEach((v) => { weekArr.push(

{v}

); }); return weekArr; }, []); const returnDay = useCallback(() => { //선택된 달의 날짜들 반환 함수 let dayArr = []; for (const nowDay of week) { const day = new Date(selectedYear, selectedMonth – 1, 1).getDay(); if (week[day] === nowDay) { for (let i = 0; i < dateTotalCount; i++) { dayArr.push(

{i + 1}

); } } else { dayArr.push(

); } } return dayArr; }, [selectedYear, selectedMonth, dateTotalCount]); return (

{yearControl()}년 {monthControl()}월

{returnWeek()}
{returnDay()}

); }; export default Calendar;

경로: src/style/calendar.css

button { cursor: pointer; } .container { width: 500px; height: 400px; margin: auto; padding: 20px 20px; border: 1px solid rgba(128, 128, 128, 0.267); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .container .title { display: flex; } .container .title > button { border: none; margin-left: 5px; height: 20px; align-self: center; background: none; } .container .title .pagination { margin-left: auto; align-self: center; } .container .title .pagination button { margin: 0 10px; border: none; background: none; } .container .week { display: flex; } .container .week .weekday { width: calc(500px / 7); text-align: center; } .container .week .sunday { color: red; } .container .week .saturday { color: blue; } .container .date { margin-top: 20px; } .container .date .weekday { width: calc(500px / 7); float: left; text-align: center; height: 50px; line-height: 50px; } .container .date .sunday { color: red; } .container .date .saturday { color: blue; } .container .date .today { background-color: rgb(88, 111, 187); color: white; font-weight: 700; border-radius: 50%; }

경로: ./package.json

{ “name”: “calendar”, “version”: “0.1.0”, “private”: true, “dependencies”: { “@testing-library/jest-dom”: “^5.16.4”, “@testing-library/react”: “^13.2.0”, “@testing-library/user-event”: “^13.5.0”, “classnames”: “^2.3.1”, “react”: “^18.1.0”, “react-dom”: “^18.1.0”, “react-scripts”: “5.0.1”, “web-vitals”: “^2.1.4” }, “scripts”: { “start”: “react-scripts start”, “build”: “react-scripts build”, “test”: “react-scripts test”, “eject”: “react-scripts eject” }, “eslintConfig”: { “extends”: [ “react-app”, “react-app/jest” ] }, “browserslist”: { “production”: [ “>0.2%”, “not dead”, “not op_mini all” ], “development”: [ “last 1 chrome version”, “last 1 firefox version”, “last 1 safari version” ] } }

4. 깃허브 코드 주소

https://github.com/6810779s/calendar

반응형

[리액트] react-calendar로 캘린더 제작: 하이라이트 기능

– 결과

현재 제작하고 있는 건 다이어리 웹이다. 언제 일기를 작성했는지 보여준다.

위 사진은 2022년 1월 3, 7, 12, 13, 15일에 작성하였다고 보여주는 예시이다.

작성 날짜들을 표시할 수 있게 하이라이트 기능을 추가해보자! 😀

– 초기 설정

공식 깃헙 레파지토리를 참고하였다.

– react-calendar 라이브러리 설치

// npm일 경우 npm install react-calendar // yarn일 경우 yarn add react-calendar

설치가 완료되었다면, 코드를 작성해준다.

-코드 작성

import React, { useState } from ‘react’; import Calendar from ‘react-calendar’; function MyApp() { const [value, onChange] = useState(new Date()); return (

); }

그럼 다음과 같은 형태의 달력이 나타난다. (글씨체는 따로 설정한 겁니다!)

‘2022년 1월’이라는 버튼을 클릭하면 월을 선택하게 바뀐다.

다음으로 예쁘게 커스텀해보겠다.

-css로 꾸미기

import ‘react-calendar/dist/Calendar.css’;

라이브러리에 있는 css 파일을 import 해오면,

다음과 같이 예쁘게 바뀌는 것을 확인할 수 있다.

하지만! 나는 커스텀할게 꽤 있기 때문에

node_modules\react-calendar\dist\Calendar.css 경로에 있는 css 파일을 복붙하여 코드를 수정하였다.

커스텀할 게 없다면 이 단계는 생략해도 무관하다.

이제 기본 설정은 완료되었고, 본격적으로 하이라이트 기능을 추가해보겠다!!

– 하이라이트 기능 추가

코드 형태는 초기 설정에 작성한 코드와 유사하며 약간의 기능만 추가하면 된다.

– CSS 코드

.highlight { background: #f3a95f; }

먼저 하이라이트가 되어야 하는 부분의 색을 정해줬다.

– 날짜 지정

const marks = [ “15-01-2022”, “03-01-2022”, “07-01-2022”, “12-01-2022”, “13-01-2022”, “15-01-2022”, ];

하이라이트가 들어갈 날짜를 배열로 작성해주었다.

– 캘린더 설정

return (

{ if (marks.find((x) => x === moment(date).format(“DD-MM-YYYY”))) { return “highlight”; } }} />

);

집중해야 할 부분은 tileClassName이다.

tileClassName 상세 설명은 깃헙을 참고하면 된다.

date와 우리가 작성한 배열인 marks를 비교하며 해당되는 날짜에 highlight를 클래스명으로 주게 된다.

이렇게 하면 moment가 undefined로 뜰 거다!!

moment를 설치하고 캘린더가 있는 소스코드에 import 해주면 해결된다.

– moment 설치

yarn add moment

– moment import

import moment from “moment”;

[참고]

참고한 코드의 댓글을 보면, 더 좋은 성능을 낼 수 있는 코드가 적혀있다.

So you have finished reading the react 달력 topic article, if you find this article useful, please share it. Thank you very much. See more: React 달력 만들기, React 달력 라이브러리, React-datepicker, React-big calendar 사용법, React-google calendar, 리액트 달력 만들기, react-big-calendar, React-calendar TypeScript

Leave a Comment