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

264
Vistas
Uncaught TypeError: r.current.contains is not a function in kendo DriopDownList

While working with Kendo React, I wanted to add a Kendo DropDownList. I tried to fill the list with data like this:

Array(8) [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…} ]
​
0: Object { id: -1, name: null }
​
1: Object { id: 1, name: "A" }
​
2: Object { id: 2, name: "B" }
​
3: Object { id: 3, name: "C" }
​
4: Object { id: 4, name: "D" }
​
5: Object { id: 5, name: "E" }
​
6: Object { id: 6, name: "F" }
​
7: Object { id: 77, name: "G" }

The data is fetched with axios and put inside useState in UseEffect:

const[sektor, setSektor] = useState([]);
...
...
useEffect(() => {   
      (async() =>{
        try{
          const resSektor = await services.getSektor();
          console.log(resSektor.data.rlista); //JSON above is this console log
          setSektor(resSektor.data.rlista);
        }
        catch(e){
          console.log(e);
        }
      })();
     
       }, []);

So, 'sektor' is used as an array of objects that will fill the Kendo dropdown:

<DropDownList data={sektor} value={sektorV} style={{marginTop:'2%'}} onChange={handleChangeSektor} textField="name" dataItemKey="id"/>
...
...
const handleChangeSektor = (event) => {
      setSektorV(event.target.value);
    };

'sektorV' is a state that saves the object that is picked from the KendoDropDown and is defined like this:

const[sektorV, setSektorV] = useState({id: -1, name: "All"});

Everything seems to be correct, but when I click on the DropDown the screen goes white and this is console logged:


Uncaught TypeError: r.current.contains is not a function
...
Uncaught TypeError: _utils__WEBPACK_IMPORTED_MODULE_2__.getItemValue(...) is null

I had a bunch of dropdowns in my current project and they all worked fine. Can anybody see the problem?

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

0

Just a hunch based on this limited code context, but I think this error is thrown because the first element has a null name property in the resSektor.data.rlista array.

Try setSektor(resSektor.data.rlista.slice(1)); to remove the null value or instead of null update that element's name property to "ALL" to match the initial sectorV state.

useEffect(() => {   
  (async() =>{
    try {
      const resSektor = await services.getSektor();
      resSektor.data.rlista[0].name = "All";
      setSektor(resSektor.data.rlista);
    } catch(e) {
      console.log(e);
    }
  })();
}, []);
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