Skip to content

Commit

Permalink
#13 Add useTravelerdata to populartravelers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 29, 2023
1 parent 905ccdc commit db70be2
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/pages/travelers/PopularTravelers.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
import React, { useEffect, useState } from "react";
import appStyles from "../../App.module.css";
import Container from "react-bootstrap/Container";
import { axiosReq } from "../../api/axiosDefaults";
import { useCurrentUser } from "../../contexts/CurrentUserContext";
import Asset from "../../components/Asset";
import Traveler from "./Traveler";
import { useTravelerData } from "../../contexts/TravelerDataContext";

const PopularTravelers = ({ mobile }) => {
const [travelerData, setTravelerData] = useState({
pageTraveler: { results: [] },
popularTravelers: { results: [] },
});
const { popularTravelers } = travelerData;
const currentUser = useCurrentUser();

useEffect(() => {
const handleMount = async () => {
try {
const { data } = await axiosReq.get(
"/travelers/?ordering=-followers_count"
);
setTravelerData((prevState) => ({
...prevState,
popularTravelers: data,
}));
} catch (err) {
console.log(err);
}
};

handleMount();
}, [currentUser]);
const { popularTravelers } = useTravelerData();

return (
<Container
Expand Down

0 comments on commit db70be2

Please sign in to comment.