I am creating Address Data fields where country->state->city
are created by using react-select.
All the data of country->state->city
is coming through API. If is it single address then there is no issue.
But I want to add multiple address. I want country->state->city
in each address.
So how can I differentiate the country->state->city
from each address block.
How can I create array of country->state->city
using react-select.
I didn't get the exact question, but will answer based on what I understood:
You can use map function, to map each address to a react-select component. and then display the component in the JSX.
const address = ['ad1', 'ad2', 'ad3'] //can be different based on your apis, it could be objects with 'house number', 'address line 1' etc.
const admap = address.map((add, index) => ( <div key={index}> // put your react select stuff </div> ))
then you can use {address} in the JSX to display the selects for each address.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.