This package can easily be used with react project within form tag to get all locations in Nigeria.
In the project directory, you can run:
- Easy to add into existing project
- Easy to style
- Get selected location on one click
- Install by executing
npm install nigeria-locations
oryarn add nigeria-locations
. - Import by adding
import States from 'nigeria-locations'
. - Use by adding
<States />
. UseonSelect
prop for getting new values.
Add nigeria-locations to your project by executing npm install nigeria-locations
or yarn add nigeria-locations
.
Here's an example of basic usage:
import React, { useState } from 'react';
import States from 'nigeria-locations';
function MyApp() {
const onChange = (state) => {
console.log(state);
};
return (
<div>
<States onSelect={onChange} />
</div>
);
}
Displays a complete, interactive select tag.
Prop name | Description |
---|---|
select-tag | Use this className to override the initial styling of the select tag |
option-tag | Use this className to override the initial styling of the tag tag |
onSelect | Create a function and pass the function as a prop to tag |
params | In the function created, pass a param in the function. Inside the function, you can get the value of the selected state, console the param in the function to see the selected state |