DEV Community

James Osho Thomas
James Osho Thomas

Posted on

How to update state React Native

` const slug = route.params.slug;

const [product, setProduct] = useState([]);

const getProduct = async () => {
const resp = await fetch(http://192.168.0.145:8000/api/v1/products/${slug});
const product = await resp.json();
setProduct(product);

}

useEffect(() => getProduct(), []);
`
My product does not update state when slug is changed

Top comments (0)