Skip to content

Commit

Permalink
➕ feat: toastify
Browse files Browse the repository at this point in the history
  • Loading branch information
Linder Hassinger committed Apr 26, 2024
1 parent d4195f4 commit 0de6566
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
21 changes: 21 additions & 0 deletions pokedex/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pokedex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"postcss": "^8.4.38",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-toastify": "^10.0.5",
"tailwindcss": "^3.4.3"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions pokedex/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import logo from "./assets/logo.svg";
import pokeSearch from "./assets/poke-search.svg";
import useGetPokemon from "./hooks/useGetPokemon";
import useInputValue from "./hooks/useInputValue";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

function App() {
const { inputValue, handleInputValue } = useInputValue();
Expand All @@ -10,6 +12,7 @@ function App() {

return (
<>
<ToastContainer />
<main className="p-6">
<div className="flex items-center gap-1">
<img src={logo} width={40} alt="" />
Expand Down
6 changes: 5 additions & 1 deletion pokedex/src/hooks/useGetPokemon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react";
import { toast } from "react-toastify";

export default function useGetPokemon(inputValue) {
const [pokemon, setPokemon] = useState(null);
Expand All @@ -8,7 +9,10 @@ export default function useGetPokemon(inputValue) {
const response = await fetch(url);

if (!response.ok) {
alert("Hubo un error");
toast.error("Hubo un error", {
autoClose: true,
closeButton: true,
});
return;
}

Expand Down

0 comments on commit 0de6566

Please sign in to comment.