Skip to content

Commit

Permalink
[FIX]: erro de renderização
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaryoshida committed Dec 6, 2023
1 parent 3bd6353 commit 4fcbd03
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions frontend/src/pages/CreateTrilhas/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {React, useState} from "react";
import React, {useState, useEffect} from "react";
import { useFormik } from "formik";
import { useNavigate } from "react-router-dom";
import { ChakraProvider } from "@chakra-ui/react";
Expand Down Expand Up @@ -42,7 +42,7 @@ const CreateTrilhas = () => {
nomeTrilha: "",
descricao: "",
serie: "",
eletivas: [],
eletivas: "",
},
validationSchema: yup.object({
nomeTrilha: yup
Expand Down Expand Up @@ -107,18 +107,20 @@ const CreateTrilhas = () => {
},
});

const fetchEletivas = async () => {
try {
const response = await axios.get('http://localhost:3001/elective/electives');
setEletivas(response.data);
} catch (error) {
console.error('Erro ao buscar eletivas:', error);
} finally {
setIsLoading(false);
}
};
useEffect(() => {
const fetchEletivas = async () => {
try {
const response = await axios.get('http://localhost:3001/elective/electives');
setEletivas(response.data);
} catch (error) {
console.error('Erro ao buscar eletivas:', error);
} finally {
setIsLoading(false);
}
};

fetchEletivas();
fetchEletivas(); // Chama a função apenas uma vez durante a montagem do componente
}, []);


return (
Expand Down Expand Up @@ -211,7 +213,7 @@ const CreateTrilhas = () => {
</Text>
): (
eletivas.map((eletiva) => (
<Checkbox value={eletiva.id}>
<Checkbox value={eletiva.name}>
{eletiva.name}
</Checkbox>
))
Expand Down

0 comments on commit 4fcbd03

Please sign in to comment.