I\'m checking out React.js and trying to figure out how this library can work together with Isotope.js. The documentation of React says that it plays nicely with other libra
I don't know how but this doesn't work for me. But if I don't use the map function and use data manually this works.
import React, {useEffect, useState, useRef} from 'react';
import options from "./Options"
import ReactDom from 'react-dom'
import Isotope from 'isotope-layout';
import ItemGrid from "./ItemGrid";
const Home = () => {
const [question, setQuestion] = useState();
const [options, setOptions] = useState([]);
// store the isotope object in one state
const [isotope, setIsotope] = React.useState(null);
useEffect(() => {
Axios.get("http://localhost:8080/laravel/voting/public/api/question/3").then((res)=>{
console.log(res.data)
setQuestion(res.data.question);
setOptions(res.data.option)
});
}, []);
useEffect(() => {
setIsotope(
new Isotope(".filter-container", {
itemSelector: ".filter-item",
layoutMode: "vertical",
getSortData : {number: '.number parseInt'}
})
);
}, []);
const changeStateLevel = ()=>{
isotope.arrange({ sortBy: "number" });
}
return (
<>
{
options.map(object=>(
{object.vote}
Cucumber
))
}
>
);
}
export default Home;