react-datepicker
CLAUDE.md8.4k starsChanged 7 years agoMITView on GitHub
Always use yarn instead of npm for all commands in this repository (yarn@4.9.2). The main entry point is src/index.tsx which exports the DatePicker component. The component hierarchy flows as follows: Positioning System: The datepicker uses @floating-ui/react (v0.27.15) for positioning the calendar relative to the input. The withFloating HOC wraps PopperComponent to provide positioning logic. Date Utilities: All date manipulation goes through date_utils.ts, which wraps date-fns (v4.1.0). This provides a consistent API across the codebase and makes it easier to maintain…
- Commits and pushes
We split this CLAUDE.md into the rules it gives an agent
18 rules. About 0 are common, 8 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 62
Date Utilities: All date manipulation goes through date_utils.ts, which wraps date-fns (v4.1.0).
- Very specific: line 95
Use eslint-disable comments for Floating UI ref accesses (e.g., popperProps.refs.setFloating, popperProps.context, arrowRef)
- Very specific: line 104
setState in effects: Avoid calling setState directly in effects.
- Very specific: line 105
When refs must be updated based on props, do it in useEffect, not during render
- Distinctive: line 121
If you need tighter integration during development:
- Very specific: line 123
Run yarn link from project root
- Distinctive: line 129
After initial setup, when making changes:
- Very specific: line 132
SCSS changes: Run yarn run css:dev && yarn run css:modules:dev
- Distinctive: line 160
When fixing bugs, always follow Test-Driven Development:
- Distinctive: line 162
Write the test first: - Create a failing test that reproduces the bug
- Distinctive: line 163
Confirm it fails: - Run the test to verify it captures the broken behavior
- Distinctive: line 165
Verify the test passes: - Run the test again to confirm the fix works
- Very specific: line 166
Run full test suite: - Ensure no regressions with yarn test:ci
- Very specific: line 168
Commit the fix: - Use a descriptive commit message referencing the issue (e.g., fix: description of fix\n\nFixes #123)
- Very specific: line 170
Create a PR: - Use gh pr create with a clear title and description that references the issue
- Distinctive: line 177
Prettier handles all code formatting: - don't worry about tabs vs spaces
- Very specific: line 178
ESLint enforces coding standards: - run yarn lint before committing
- Distinctive: line 180
Tests are required: - add Jest tests for new functionality
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Package Manager
Always use yarn instead of npm for all commands in this repository (yarn@4.9.2).
Common Commands
Development
yarn install- Install dependencies (run from project root)yarn start- Start the docs-site development server at http://localhost:5173yarn build- Full production build (JS + CSS in all formats)yarn build-dev- Development build with file watching
Testing and Quality
yarn test- Run the full test suite (Jest with ts-jest)yarn test src/test/calendar_test.test.tsx- Run a single test fileyarn test:watch- Run tests in watch modeyarn test:ci- Run tests with coverage for CIyarn lint- Run both ESLint and Stylelintyarn eslint- Run ESLint on src directoryyarn sass-lint- Run Stylelint on SCSS filesyarn type-check- Run TypeScript type checking without emitting filesyarn prettier- Format all JS/JSX/TS/TSX filesyarn prettier:check- Check formatting without making changes
Building Individual Pieces
yarn build:src- Build JS using Rollupyarn js:dev- Build JS in watch modeyarn css:prod- Build minified production CSSyarn css:dev- Build expanded development CSSyarn css:modules:prod- Build CSS modules (minified)yarn css:modules:dev- Build CSS modules (expanded)
Architecture Overview
Component Hierarchy
The main entry point is src/index.tsx which exports the DatePicker component. The component hierarchy flows as follows:
DatePicker (index.tsx) - Main component, class-based
├── PopperComponent (popper_component.tsx) - Positioned calendar container
│ ├── withFloating HOC (with_floating.tsx) - Floating UI integration
│ ├── Portal (portal.tsx) - Optional portal rendering
│ └── TabLoop (tab_loop.tsx) - Keyboard navigation wrapper
│ └── Calendar (calendar.tsx) - Core calendar logic
│ ├── ClickOutsideWrapper - Handles outside clicks
│ ├── Month/Year/Time components - Date selection UI
│ └── Various dropdowns for date navigationKey Architectural Patterns
Positioning System: The datepicker uses @floating-ui/react (v0.27.15) for positioning the calendar relative to the input. The withFloating HOC wraps PopperComponent to provide positioning logic.
Date Utilities: All date manipulation goes through date_utils.ts, which wraps date-fns (v4.1.0). This provides a consistent API across the codebase and makes it easier to maintain date-related logic.
State Management: The main DatePicker component is class-based and manages state internally. Most child components are controlled components that receive props and callbacks.
Styling: SCSS source files live in src/stylesheets/. The build process generates multiple CSS outputs:
- Regular CSS:
react-datepicker.css(dev) andreact-datepicker.min.css(prod) - CSS Modules:
react-datepicker-cssmodules.cssandreact-datepicker.module.css
Build Output
Rollup (configured in rollup.config.mjs) generates multiple bundle formats in the dist/ directory:
- UMD:
react-datepicker.jsandreact-datepicker.min.js(browser) - CommonJS:
index.js(Node/bundlers) - ES Modules:
index.es.js(modern bundlers) - Types:
index.d.ts(TypeScript definitions)
Testing Architecture
Tests use Jest with @testing-library/react and are located in src/test/. The test setup:
- Configuration:
jest.config.js - Setup file:
src/test/index.ts - Helper components:
src/test/helper_components/ - Coverage is collected and reported to Codecov
Important for tests: Some components use ShadowDOM for testing. The shadow_root.tsx helper uses flushSync to ensure synchronous updates required by tests.
Floating UI Integration Notes
The codebase uses @floating-ui/react for positioning. Important: The Floating UI library requires refs and context to be accessed during render, which is by design. When fixing linting errors:
- Use
eslint-disablecomments for Floating UI ref accesses (e.g.,popperProps.refs.setFloating,popperProps.context,arrowRef) - These are not violations of React best practices—they're intentional library usage
- See
popper_component.tsxandwith_floating.tsxfor examples
React Hooks Rules
This codebase uses eslint-plugin-react-hooks v7.0.1+ which has strict rules about:
- Ref access during render: Generally not allowed, but see Floating UI exception above
- setState in effects: Avoid calling setState directly in effects; use
flushSyncwhen synchronous updates are needed - When refs must be updated based on props, do it in
useEffect, not during render
Development Workflow
Local Development Setup (Full)
- Install node >=16.0.0 and yarn >=4.6.x
yarn installfrom project rootyarn buildfrom project root (generates dist/ directory)yarn startto launch docs at http://localhost:5173- In a new terminal, run
yarn build-devto auto-rebuild on changes
Note: The docs-site uses a portal: dependency ("react-datepicker": "portal:../") which links to the parent project. Changes to the main package are reflected in the docs when you rebuild.
Alternative Setup with yarn link (from CONTRIBUTING.md)
If you need tighter integration during development:
- Run
yarn linkfrom project root - Run
cd docs-site && yarn link react-datepicker - Then follow steps above
Quick Development Workflow
After initial setup, when making changes:
- JS/TS changes: Changes auto-rebuild if
yarn build-devis running - SCSS changes: Run
yarn run css:dev && yarn run css:modules:dev
Pre-commit Hooks
The repo uses Husky with lint-staged. On commit:
- Prettier formats staged files automatically
- Files are automatically added to the commit (via
git addin lint-staged config)
Dependencies
Core Runtime Dependencies
reactandreact-dom(^16.9.0 || ^17 || ^18 || ^19) - peer dependenciesdate-fns(^4.1.0) - Date manipulation library@floating-ui/react(^0.27.15) - Positioning engineclsx(^2.1.1) - Conditional className utility
Important Dev Tools
- Build: Rollup with Babel and TypeScript plugins
- Testing: Jest, ts-jest, @testing-library/react, jest-axe
- Linting: ESLint 9, TypeScript ESLint, Stylelint
- Formatting: Prettier 3.4.2
- CSS: Sass 1.93.2
Bug Fix Workflow (TDD)
When fixing bugs, always follow Test-Driven Development:
- Write the test first - Create a failing test that reproduces the bug
- Confirm it fails - Run the test to verify it captures the broken behavior
- Implement the fix - Make the minimal code change to fix the issue
- Verify the test passes - Run the test again to confirm the fix works
- Run full test suite - Ensure no regressions with
yarn test:ci - Create a branch -
git checkout -b fix/descriptive-branch-name - Commit the fix - Use a descriptive commit message referencing the issue (e.g.,
fix: description of fix\n\nFixes #123) - Push the branch -
git push -u origin fix/descriptive-branch-name - Create a PR - Use
gh pr createwith a clear title and description that references the issue - Return to main -
git checkout mainto prepare for the next task
This ensures every bug fix has regression coverage and documents the expected behavior.
Code Conventions
- Prettier handles all code formatting - don't worry about tabs vs spaces
- ESLint enforces coding standards - run
yarn lintbefore committing - TypeScript strict mode - the codebase is fully typed
- Tests are required - add Jest tests for new functionality
- Accessibility matters - maintain ARIA attributes and keyboard navigation
Trending
Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Who's talking about Hacker0x01/react-datepicker
- react/jsx“Proposal: Namespaces for passing nested data structures”GitHub · May 22, 2017 · 66 reactions
- Stack Overflow“How can I style react-datepicker?”Stack Overflow · Jan 20, 2021 · 25 votes
- Stack Overflow“Getting a RangeError: Invalid Time Value when using React datepicker”Stack Overflow · Dec 17, 2019 · 24 votes
- Stack Overflow“React Date Picker is Being Hidden Behind Overflow Parent (popover fixed placement issue)”Stack Overflow · Oct 8, 2020 · 19 votes
- Stack Overflow“DatePicker in Redux Form”Stack Overflow · Feb 23, 2017 · 13 votes
The biggest 5 of 81 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 81
Talked about on GitHub, Stack Overflow and Bluesky (81 times).
On GitHub · 50
- May 22, 2017Proposal: Namespaces for passing nested data structures — react/jsx66 reactions · 19 comments
- Feb 7, 2017Weird focus behaviour wiht react-datepicker — JedWatson/react-select10 reactions · 7 comments
- Jun 24, 2021[react-datepicker] upgrade react datepicker v4 & popper v2 — DefinitelyTyped/DefinitelyTyped9 reactions · 9 comments
- Jan 6, 2025Fix for compatible with React 19 — react-dropzone/react-dropzone8 reactions · 8 comments
- Apr 3, 2017Make timepicker's popup similar to "Tethered component" (like react-datepicker) which positions according to scroll — react-component/time-picker8 reactions · 4 comments
45 more on GitHub
- Jun 3, 2021[react-datepicker] Custom popper.js modifiers — DefinitelyTyped/DefinitelyTyped5 reactions · 18 comments
- Feb 2, 2024[@types/react-datepicker] Update types for v6.0 — DefinitelyTyped/DefinitelyTyped4 reactions · 10 comments
- Jan 26, 2021Feat: Add content search filters — tracim/tracim3 reactions · 7 comments
- Nov 27, 2024Remove prop-types when unused — e18e/ecosystem-issues2 reactions · 3 comments
- Apr 10, 2021getWeekOfYear change is breaking react-datepicker with no locale — date-fns/date-fns2 reactions · 4 comments
- Dec 21, 2025chore(deps): bump react-datepicker from 2.16.0 to 9.1.0 in /apps/frontend — SimpleAccounts/SimpleAccounts-UAE1 reaction · 1 comment
- Jul 30, 2025chore(deps): update e2e tests — mastra-ai/mastra1 reaction · 5 comments
- Dec 1, 2023build(deps): bump react-datepicker from 4.23.0 to 4.24.0 — todo-lists-app/frontend1 reaction
- Nov 22, 2023build(deps): bump react-datepicker from 4.21.0 to 4.23.0 — todo-lists-app/frontend1 reaction
- Oct 18, 2023build(deps): bump react-datepicker from 4.20.0 to 4.21.0 — todo-lists-app/frontend1 reaction · 1 comment
- Oct 10, 2023build(deps): bump react-datepicker from 4.19.0 to 4.20.0 — todo-lists-app/frontend1 reaction · 1 comment
- Oct 9, 2023build(deps): bump react-datepicker from 4.18.0 to 4.19.0 — todo-lists-app/frontend1 reaction · 1 comment
- Oct 3, 2023fix: update lib calendar — QueroDelivery/quero-components-web1 reaction
- Sep 18, 2023build(deps): bump react-datepicker from 4.17.0 to 4.18.0 — todo-lists-app/frontend1 reaction · 1 comment
- Sep 11, 2023build(deps): bump react-datepicker from 4.16.0 to 4.17.0 — todo-lists-app/frontend1 reaction · 1 comment
- Jun 13, 2023[FEATURE][SC-40667] Add range modifiers for year calendar — opendatasoft/react-datepicker1 reaction · 1 comment
- Dec 11, 2019Type date manually /// fix date input autocomplete — HSLdevcom/jore-map-ui1 reaction
- Dec 14, 2017Add missing type (customInputRef) on react-datepicker (introduced in 0.62.0) — DefinitelyTyped/DefinitelyTyped1 reaction · 2 comments
- Oct 28, 2026chore(deps): bump react-datepicker from 4.25.0 to 9.1.0 — KeepSoftwareSimple/compass-calendar0 reactions · 1 comment
- Oct 25, 2026chore(deps): bump react-datepicker from 7.6.0 to 9.1.0 in /web — ianmcgregor2904git/Onyx0 reactions · 1 comment
- Oct 25, 2026[Snyk] Upgrade react-datepicker from 7.3.0 to 7.6.0 — ac-bushrakhan/brokencrystalspublic0 reactions · 1 comment
- Oct 22, 2026chore(deps): bump react-datepicker from 6.9.0 to 9.1.0 in /keep-ui — fadewalk/gengfu0 reactions
- Oct 16, 2026[Snyk] Upgrade react-datepicker from 7.3.0 to 7.6.0 — daveglover90/brokencrystals0 reactions · 2 comments
- Oct 15, 2026Bump react-datepicker from 7.6.0 to 9.1.0 — TheRealOwenRees/echecsfrance0 reactions · 1 comment
- Oct 10, 2026Update dependency react-datepicker to v9 — UniversityOfHelsinkiCS/lomake0 reactions
- Oct 10, 2026build(deps): bump react-datepicker from 7.6.0 to 9.1.0 — ulams-dev/ulams0 reactions · 1 comment
- Oct 5, 2026chore(deps): bump react-datepicker from 8.3.0 to 9.1.0 — MagalDevs/Front_MedReminder0 reactions · 1 comment
- Oct 2, 2026[Snyk] Upgrade react-datepicker from 7.3.0 to 7.6.0 — preetiparameswaransnyk/brokencrystals0 reactions · 1 comment
- Oct 1, 2026[Snyk] Upgrade react-datepicker from 7.3.0 to 7.6.0 — ac-bushrakhan/brokencrystalspublic0 reactions · 1 comment
- Sep 21, 2026Bump react-datepicker from 7.6.0 to 9.1.0 — 14zy/aravt-dev0 reactions · 1 comment
- Aug 26, 2026build(deps): bump react-datepicker from 8.4.0 to 9.1.0 in /examples/hello-world — chdcgood85/react-datepicker0 reactions
- Aug 25, 2026Bump react-datepicker from 8.0.0 to 9.1.0 — OpusLearning/events-platform-frontend0 reactions
- Aug 24, 2026build(deps): bump react-datepicker from 8.10.0 to 9.1.0 — sapienzafoilingteam/sapienzafoilingteam0 reactions · 1 comment
- Aug 21, 2026[Snyk] Upgrade react-datepicker from 7.3.0 to 7.6.0 — usmankhan-se/brokencrystals0 reactions · 1 comment
- Aug 15, 2026chore(client): bump react-datepicker from 4.25.0 to 9.1.0 in /client — GirMart-sdk/Hotel-DEVCO0 reactions
- Aug 14, 2026fix(deps): bump react-datepicker from 6.9.0 to 9.1.0 — IVFSS/blockatnet-1230 reactions
- Aug 10, 2026Bump react-datepicker from 8.10.0 to 9.1.0 in /new_client — EliteKnightWork/AIWorkflow-PublicSales0 reactions
- Aug 6, 2026chore(deps): bump react-datepicker from 8.10.0 to 9.1.0 — emmanuel-ggwp/acreditacion_prueba20 reactions
- Aug 3, 2026chore(deps): bump react-datepicker from 7.6.0 to 9.1.0 — VerifiedInc/shared-ui-elements0 reactions · 2 comments
- Jul 21, 2026Bump react-datepicker from 7.6.0 to 9.1.0 — dev-lou/smart-gate0 reactions · 1 comment
- Jan 9, 2026build(deps): bump react-datepicker from 4.7.0 to 9.1.0 — superdesk/newsroom-core0 reactions · 2 comments
- Nov 17, 2025Bump react-datepicker from 4.25.0 to 8.9.0 — albertolive/culturaCardedeu0 reactions · 3 comments
- Feb 1, 2025chore(deps): Bump the react-datepicker group across 1 directory with 2 updates — marcobiedermann/countdown0 reactions
- Nov 18, 2024fix(deps): update dependency react-datepicker to v4.25.0 — textkernel/oneui0 reactions · 1 comment
- Jan 26, 2023Invalid comparison on identical invalid date objects — date-fns/date-fns0 reactions
On Stack Overflow · 30
- Jan 20, 2021How can I style react-datepicker?25 votes
- Dec 17, 2019Getting a RangeError: Invalid Time Value when using React datepicker24 votes
- Oct 8, 2020React Date Picker is Being Hidden Behind Overflow Parent (popover fixed placement issue)19 votes
- Feb 23, 2017DatePicker in Redux Form13 votes
- Jul 10, 2017Add style/class to react-datepicker12 votes
25 more on Stack Overflow
- Sep 12, 2019How to bundle CSS with a component as an npm package?10 votes
- Dec 31, 2018How to customize the style in react-datepicker?10 votes · 3 answers
- May 19, 2017React Datetime Picker Component with Semantic UI React example8 votes
- Dec 6, 2018React-Datepicker handleChange with multiple name attributes6 votes · 3 answers
- Mar 2, 2018How do I facilitate easy year-to-year navigation using react-datepicker?5 votes · 2 answers
- Jan 13, 2015react-datepicker with no initial value5 votes · 2 answers
- Jun 11, 2022How to add custom style to React Datepicker (HackerOne)?4 votes · 2 answers
- Sep 23, 2021Multi Language React DatePicker3 votes · 1 answer
- Apr 17, 2019React-Datepicker MomentJS Invalid Date3 votes
- Jun 13, 2015Running into problems using React Datepicker with rails3 votes · 1 answer
- Sep 21, 2021how to validate a manual input in the keyboarddatepicker2 votes
- Jul 19, 2021Error when I import .css file from node-module2 votes
- Mar 16, 2021React JS DateTimePicker issue - Changing the time 12:01pm and 1:59pm - updated into next date2 votes
- Jul 4, 2019React-DatePicker - Format not Defined2 votes
- Dec 9, 2018Uncaught RangeError: `options.awareOfUnicodeTokens` must be set to `true` to use `YYYY` In date picker2 votes · 1 answer
- Aug 7, 2017Bootstrap datepicker not working with Webpack2 votes
- May 29, 2017React js datetimepicker usage inside component2 votes
- Apr 19, 2016react-datepicker value isn't changed when new date is selected2 votes · 1 answer
- Jun 20, 2024Why is excludScrollbar property required for react-datepicker?1 vote
- May 3, 2024How to hide the react-datepicker header?1 vote
- Jun 30, 2020ReactJs - Formatting date and time1 vote
- Dec 12, 2017How to disable <react-date-picker> component on a button click1 vote
- Oct 29, 2017Loading plugin CSS with Encore/Symcony21 vote
- May 19, 2017React Datetime Picker Component with Semantic UI React example1 vote
- May 11, 2017How to trigger a change event using react1 vote · 1 answer
On Bluesky · 1
- Sep 27, 2024📦 Hacker0x01 / react-datepicker ⭐ 8,050 (+74) 🗒 TypeScript A simple and reusable datepicker component for React — @github-trending-js.bsky.social1 likes and repost
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

