Repository navigation
feat: support React 19 - #45
Merged
Merged
Conversation
React 19 ignores `defaultProps` on function components, so on React 19
the geolocation button disappeared and the input lost its default
placeholder. Defaults are now parameter defaults in the render function
(`geolocation = true`, `options` as a module-level constant,
`placeholder = 'Search places...'` passed explicitly to the input).
- peerDependencies: react and react-dom widened to ^16 || ^17 || ^18 || ^19
- types: use `React.JSX.Element` (global `JSX` namespace is gone in
@types/react 19) and widen @types/react to ^18.2.58 || ^19 so npm
dedupes it with the app's version
- build: rollup config uses `with { type: 'json' }` (Node 22 dropped
import assertions, `assert` failed the build)
- version 2.3.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o 19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apps on React 16 to 18 that read or mutate PlaceKit.defaultProps keep working, and the @types/react range no longer pulls React 19 types into React 18 projects on fresh installs. Parameter defaults still cover React 19. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Closes #44 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds React 19 support. Drop-in upgrade for React 16, 17 and 18.
Problem
React 19 no longer applies
defaultPropsto function components (includingforwardRef) created through the JSX runtime. With 2.2.2 on React 19:geolocationisundefined)npm installfails withERESOLVE(peer range stops at^18)Changes
PlaceKit: defaults are now also declared as parameter defaults (geolocation = true,options = DEFAULT_OPTIONS,placeholder = DEFAULT_PLACEHOLDER).placeholderis passed explicitly to<input>since it is no longer part of the rest spread.DEFAULT_OPTIONSis a module-level constant to keep a stable reference.PlaceKit.defaultPropsis kept with the same values, so code that reads or mutates it keeps working on React 16 to 18. React 19 ignores it and logs no warning for it.peerDependencies:reactandreact-domwidened to^16 || ^17 || ^18 || ^19.index.d.ts: return typeJSX.Element->React.ReactElement.@types/react19 removed the globalJSXnamespace;React.ReactElementis available in all@types/reactversions.rollup.config.js: JSON import useswithinstead ofassert(assertis rejected by Node 22).@types/reactstays at^18.2.58on purpose: widening it to^19makes fresh installs of React 18 TypeScript apps resolve@types/react19.Compatibility testing
Published 2.2.2 vs this branch, installed in otherwise identical consumer apps (React StrictMode, API mocked). Each scenario runs the same flow (type, keyboard navigation, pick, clear, Escape, geolocation toggle) and compares DOM, screenshots (pixel diff), handler calls, outgoing requests and console output.
--legacy-peer-deps@types/reactresolution, sametscoutput@types/react19Cannot find namespace 'JSX'error fixedScenarios covered: default props, custom/empty/
null/undefinedplaceholder,geolocation={false},disabled, HTML attributes,defaultValue, fulloptionswith customformat, inlineoptionsre-created on each render, all event handlers, object and callback refs,usePlaceKit, reading/mutating/reassigningPlaceKit.defaultProps.Only difference on React 16 to 18: when
placeholderis passed before other props, it is emitted later in the<input>attribute list. No visual or behavioral change. Bundle size: +0.08 kB gzipped.Known issues (unchanged by this PR)
@placekit/client-jstype declarations fail withskipLibCheck: false(TS1016).require('@placekit/autocomplete-react')from plain Node fails ("type": "module"with a.cjs.jsentry). Bundlers are not affected.'use client'directive: Next.js app router users need a client wrapper.🤖 Generated with Claude Code