Giter VIP home page Giter VIP logo

punk-api's Introduction

Figma

HTML5CSS3SASSJavaScriptReact

JavaSpringMySQLGoogle Cloud

Hi, Im Joe and I'm a junior full stack developer. I'm based in the East Midlands. I have a keen interest in back-end development and Cloud. I am currently working for _Nology.

🔎Take a look at some of my projects:


🌤Outside of coding:

⚽️ I play for a local football team.
🏋🏻 I go to the gym regularly.
🎮 I enjoy gaming in my spare time.

Joe's GitHub stats.

punk-api's People

Contributors

joebrentnall25 avatar

Watchers

 avatar  avatar

punk-api's Issues

Feedback

Site

  • Site is usable on mobile, but feels quite squished, especially around the search/ filter section. Try using padding for elements like that so they always have a bit of space around.
  • Great job getting the search to trigger another network request

Code

  • Your useEffect’s dependency array should at least include the function’s dependencies. You can add more if you want it to be triggered more often. In this case it will require you to use React’s Callback functions, which we haven’t covered, however I would definitely recommend reading up on the docs here
// your code
useEffect(() => {
    getData(formatBeerName());
  }, [searchTerm, isHighAbv, isClassicRange, isAcidic]);

// using just the "required" dependencies (although you can add more)
useEffect(() => {
    getData(formatBeerName());
  }, [getData, formatBeerName]);
  • Remember that return immediately leaves the function, there’s a couple of places you could remove some code:
//your code 
const formatBeerName = () => {
    if (searchTerm !== "") {
      return (
        baseUrl +
        "beer_name=" +
        searchTerm.replace(" ", "_") +
        "&" +
        generateUrl()
      );
    } else {
      return baseUrl + generateUrl();
    }
  };

//switch the statement around, using a "guard clause" to leave the function asap
const formatBeerName = () => {
    if (searchTerm === "") {
      return baseUrl + generateUrl();
    }

    return (
      baseUrl +
      "beer_name=" +
      searchTerm.replace(" ", "_") +
      "&" +
      generateUrl()
    );
  };
  • Similarly we don’t need the else statement here:
// your code
.then((data) => {
  if (isAcidic) {
    const filteredData = data.filter((beer) => {
      return beer.ph < 4;
    });
    setBeers(filteredData);
  } else {
    setBeers(data);
  }
});

// we always do "setBeers" with some data, so we could remove that else
.then((data) => {
  if (isAcidic) {
    data = data.filter((beer) => {
      return beer.ph < 4;
    });
  }
  setBeers(data);
});
  • You don’t need to wrap in a fragment <></>, in your case you’re only returning a single element from the function. Only use them when you want to return > 1 sibling elements.
  • Overall, great work! The way you’ve split up your components is great, really clear and readable structure etc. The feedback I’ve given is pretty nitpicky and more to do with either performance or cleaner code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.