Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@placekit/autocomplete-react
Advanced tools
All-in-one autocomplete experience for your React web apps
Quick start • Component properties • Custom hook • Documentation • License
PlaceKit Autocomplete React Library is a React wrapper of PlaceKit Autocomplete JS. It features a compoment ready to use, and a custom hook for custom implementations. It also is TypeScript compatible.
First, install PlaceKit Autocomplete React using npm package manager:
npm install --save @placekit/autocomplete-react
Then import the package and perform your first address search:
import { PlaceKit } from '@placekit/autocomplete-react';
const MyComponent = (props) => {
return (
<PlaceKit apiKey="<your-api-key>" />
);
};
export default MyComponent;
Also, import default style from @placekit/autocomplete-js/dist/placekit-autocomplete.css
(@placekit/autocomplete-js
is set as a dependency of this package and will automatically be installed). It will style the suggestions list and the input.
If you have trouble importing CSS from node_modules
, copy/paste its content into your own CSS.
<PlaceKit
apiKey="<your-api-key>"
useGeolocation={false} // hide "ask geolocation" button
className="your-custom-classes" // <div> wrapper custom classes
// PlaceKit Autocomplete JS options
options={{
offset: 4,
template: (item, index) => {},
formatValue: (item) => {},
timeout: 5000,
maxResults: 5,
types: ['city'],
language: 'fr',
countries: ['fr'],
coordinates: '48.86,2.29',
}}
// handlers
onOpen={() => {}}
onClose={() => {}}
onResults={(query, results) => {}}
onPick={(value, item, index) => {}}
onError={(error) => {}}
onFreeForm={(isFreeForm) => {}}
onGeolocation={(hasGeolocation, position) => {}}
// and any other property will be forwared to the <input> element
id="my-input"
name="address"
placeholder="Search places..."
disabled={true}
/>
Please refer to PlaceKit Autocomplete JS documentation for more details about the options.
A few additional notes:
<input>
is using React ref
attribute. It is therefore an uncontrolled component and should be treated as such.If our component doesn't suit your needs, you can build your own using the provided custom hook usePlaceKit()
:
import { usePlaceKit } from '@placekit/autocomplete-react';
const MyComponent = (props) => {
const { target, client, isFreeForm, hasGeolocation } = usePlaceKit('<your-api-key>', {});
return (
<input ref={target} />
);
};
Please refer to PlaceKit Autocomplete JS documentation for more details about the options.
A few additional notes:
target
is a React ref
object.options.handlers
, but also be set with client.on()
(better use a useState()
in that case).usePlaceKit
second argument (options), this will cause an infinite update loop as a destructured object will constantly be a fresh new value by nature.isFreeForm
and hasGeolocation
are separately set inside the hook, as client.isFreeForm
and client.hasGeolocation
are stateless.⚠️ NOTE: you are not allowed to hide the PlaceKit logo unless we've delivered a special authorization. To request one, please contact us using our contact form
PlaceKit Autocomplete React Library is an open-sourced software licensed under the MIT license.
FAQs
PlaceKit Autocomplete React library
The npm package @placekit/autocomplete-react receives a total of 295 weekly downloads. As such, @placekit/autocomplete-react popularity was classified as not popular.
We found that @placekit/autocomplete-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.