Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-loqate

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-loqate

This is a React implementation of the loqate APIs. It features an input, typing in which will result in a list of address options. Clicking an option will trigger your callback with that option.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.1K
increased by39.61%
Maintainers
1
Weekly downloads
 
Created
Source

React-Locate

This is a React implementation of the loqate APIs. It features an input, typing in which will result in a list of address options. Clicking an option will trigger your callback with that option.

Usage

Notes

You must polyfill fetch.

Installation

npm install react-loqate

Example

import AddressSearch from 'react-loqate';

// ...

<AddressSearch
  locale="en-GB"
  apiKey="AA11-AA11-AA11-AA11"
  onSelect={(address) => console.log(address)}
/>;

Props

nametyperequiredexampledescription
apiKeystringyes"AA11-AA11-AA11-AA11"Loqate API key
localestringyes"en-GB"Language to be used
onSelect(address) => voidyesaddress => console.log(address)Callback with for Loqate response
countriesstring[]no["GB", "NL"]Countries to search in
limitnumberno10Number of options to show
classNamestringno"address-search-box"Classname for the component wrapper
classes{ input?: string, list?: string, listItem?: string}no{ list: 'list' }Classnames for the components
componentssee Customizationnosee CustomizationComponents to overwrite the default ones
inlinebooleannotrueRender results inline with the input
debouncenumberno100Debounce the calls to the Loqate API

Customization

You can either style the default input, list and listItem with their respective classes or replace them completely by passing in your own components in the components prop.

List component must be able to accept a ref! All components must pass down their props!

import React from 'react';
import AddressSearch from 'react-loqate';
// to use the default styles for the default components
import 'react-loqate/dist/react-loqate.cjs.development.css';

const AddressSearchInput = (props): JSX.Element => {
  return (
    <input
      placeholder={'start typing your address or postcode'}
      autocomplete="chrome-off"
      {...props}
    />
  );
};

<AddressSearch
  locale="en-GB"
  apiKey="AA11-AA11-AA11-AA11"
  countries={['GB']}
  components={{ Input: AddressSearchInput }}
  className="address-search-box"
  classes={{ list: 'styled-list' }}
  onSelect={(address) => console.log(address)}
  inline
  debounce={100}
/>;

Keywords

FAQs

Package last updated on 26 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc