Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

355
Vistas
ant d select from array, react, js
/* eslint-disable import/named */
/* eslint-disable no-unused-vars */
import React from "react";
import { withRouter} from "react-router-dom";
import PropTypes from "prop-types";
import {  Select } from "antd";

const { Option } = Select;

const selectProps = {
  mode: "multiple",
  maxTagCount: "responsive",
  showSearch: true,
  showArrow: true,
  dropdownStyle: { zIndex: 2000 },
  filterOption: (input = "", option = "") =>
    option?.children?.toLowerCase()?.indexOf(input?.toLowerCase()) >= 0
};

const SelectD = ({}) => {


  const List = ["one","two","three"]

  return (
    <div>
      <>
        <Row gutter={[16, { xs: 8, sm: 16, md: 24, lg: 32 }]}>
          <Col span={16}>
          
                  <Form.Item label="List" name="List" fieldKey="List">
                    <Select {...selectProps}>{List}</Select>
                  </Form.Item>
        
          </Col>
        </Row>
        <Divider />

        <Row >
  
          <Button className="next" htmlType="submit">
            Confirm
          </Button>
        </Row>
      </>
    </div>
  );
};

so I have an array List=["one", "two", "three"] These vals i need to send in the select dropdown form ant design https://codesandbox.io/s/z8nf4?file=/index.js similar to this code but instead i need to send an array like this

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Simply reproduce the code you saw in the sandbox you linked:

// ....
// ....
const SelectD = ({}) => {


  const List = ["one","two","three"]

  return (
    <div>
      <>
        <Row gutter={[16, { xs: 8, sm: 16, md: 24, lg: 32 }]}>
          <Col span={16}>
          
                  <Form.Item label="List" name="List" fieldKey="List">
                    <Select {...selectProps}>{List.map(item => (<Option key={item}>item</Option>)}</Select>
                  </Form.Item>
        
          </Col>
        </Row>
        <Divider />

        <Row >
  
          <Button className="next" htmlType="submit">
            Confirm
          </Button>
        </Row>
      </>
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza Denunciar

0

This is working code from your sandbox:

import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Select } from "antd";

const { Option } = Select;

const children = [];
const Lists = ["one", "two", "three"];
Lists.map((item, index) => {
  children.push(<Option key={index}>{item}</Option>);
});

function handleChange(value) {
  console.log(`selected ${value}`);
}

ReactDOM.render(
  <>
    <Select
      mode="multiple"
      allowClear
      style={{ width: "100%" }}
      placeholder="Please select"
      defaultValue={[]}
      onChange={handleChange}
    >
      {children}
    </Select>
  </>,
  document.getElementById("container")
);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda