Category: Coursera

  • React State | Front-end Web Development

    A new concept I’m starting to learn in my Coursera course on React Basics (view post series here) is React “States.” States in React is an interesting way of storing the “state” or current information about a variable or function.

    As a new topic, I’m still learning how React works. For an actual professional, please refer to a better explanation.

    The first example of utilizing state is the “React.useState” hook. To use useState, you assign it to two array values that usually consist of one variable storing the value and another variable to set the value of the state. For example:

    import { useState } from 'react';
    
    function exampleApp() {
        const [user, setUser] = useState("ezra");
        
    }

    First, we import the state hook. Then, in the function, we assign two variables to the useState hook. Inside of the state, it has “Ezra,” which, in this case, sets the default value. If we wanted to add a function to update the state to a value, we could do so as follows:

        
        function updateUser(e) {
            setUser(e.target.value);
        }
    

    Coursera outlines that you generally want to utilize separate functions to handle events. In this case, we have a function that, when called in combination with an input field, will grab the input’s value (e.target.value). We use the setUser that we already declared earlier.

    The complete component example they taught me was:

    import { useState } from 'react';
    
    function ExampleApp() {
        const [user, setUser] = useState("ezra");
    
        function updateUser(e) {
            setUser(e.target.value);
        }
        return (
            <div>
                <h1>{user}</h1>
                <input onInput={updateUser}></input>
            </div>
        )
    }
    export default ExampleApp;

    This creates a page with an H1 element and an Input field. By default, H1 says “Ezra,” but when you type into the input field, it actively changes to what you type.

    example code demonstrated for useState

    It is an excellent and useful concept that will probably be used frequently in future React programming. Coursera also outlined a general guideline for creating components, specifically when and when not to use states.

    As the name implies, you have Stateless and Stateful components, one without any state declarations and others with state declarations. It goes to the basics of how you want things formatted and makes it much easier to later grab the state of an object by passing it down from a parent to a child component rather than having to reinstate that state in each element.

    example of stateful and stateless components in react
    credit: Coursera.org

    States in react go a lot deeper and a lot more complex, but I’m excited to learn more about it.

  • Meta Front-End Developer Course | 2 Months in

    Meta Front-End Developer Course | 2 Months in

    I’m about two months into my Front End Web Development course, and it’s about time I update.

    As of this writing, I’ve completed four out of nine of the certificate program’s courses. Since my last post, I’ve finished “Programming with Javascript,” “Version Control,” and “HTML and CSS in Depth.” I’m currently in the middle of “React Basics.”

    Programming with Javascript

    So far, this is one of my favorite courses in the program. This is mainly because it’s the only language I never really understood the basics of. It covers the basics from logging into the console to editing and integrating with HTML, how to use event handlers, and editing basic HTML with the console in inspect element.

    One of the more significant concepts introduced was OOP or Object-Oriented Programming. OOP is a recommended programming model for developing applications, where some parts of a website are thought of as modules that can be removed, duplicated, and quickly edited for reusability.

    For example, instead of writing new code every time you want to show the latest blog post, you can create a reusable template that knows how to do this. Then, whenever you need it, you can use that template to automatically grab and display the newest blog post on any page without having to write the code again. A big part of that is being demonstrated in my current course I’m taking on React Basics.

    There’s a much better explanation of how it works and more in-depth here.

    Version Control

    Version control covers the basics of GitHub. As with Javascript, this course was also informative. I’ve used GitHub occasionally for small projects and downloaded many open-source apps, but I never really understood how to use it and how it works. This course covered creating repositories, forking, branching, and basic terminal commands.

    One of the neat things I learned about GitHub that I previously did not know about is the branching system for repositories. In a barebones repository, you have the Main branch, which has the (usually) fully fleshed-out main releases for a project. For example, I’m developing docs for the Drone Project (https://ezraharris.com/category/tech/drone/ series I’m doing on building drones for a drone show). With that, I chose a free template for creating docs called “Read-the-Docs.” Read the Docs has a template with GitHub, which makes it super easy to create a copy from the template page and host it for free using their deployment system. The branching is part of the automatic deployment system; I have two branches in GitHub: a Testing branch and a Main branch. I can make changes to the testing branch that may break the formatting, but that’s not on the main page and won’t affect the primary traffic of users. I can preview edits before pushing the testing branch into the main branch.

    GitHub has much better documentation on using branching and managing pull requests here.

    HTML and CSS in Depth

    This also introduced many new concepts I had no idea were natively possible, like animations, using keyframes for more than just linear animations, and creating super smooth effects with only a couple of lines of code.

    At the end of this course, I had to create a basic homepage using the concepts covered in the course. I was given a choice of four clients. I ended up choosing Lucky Shrub. I was provided a basic description with info about the client, logos, and a couple of preparation videos outlining the site’s basic framework I would create.

    Screenshot of Luckshrub's client option given by coursera

    What made this assignment different from the other courses was the peer-reviewed grading. This is where I had some issues with Coursera. The downside is that they only support uploading HTML and CSS files, for the final project, making it challenging to review my peers’ websites because the links between files and folder structures were strange or because they used images outside of what Coursera provided. In the end, it made for a more complicated grading system than what it needed to be.

    I ended up uploading the whole site to a GitHub repository and hosted it on Pages.dev. Cloudflare provides free basic web hosting and testing applications. (You can view my finished site for the project here)

    I think it’d be a much easier process if Coursera worked with Pages.dev and/or Github to host the sites for previews instead of the mangled way of downloading and hosting it locally they have now.

    Preview of my homepage assignment for Coursera

    Overall, I enjoyed all of the courses, but Javascript and React are quickly becoming the most interesting.

  • Meta Front-End Developer Course – Week ONE

    Meta Front-End Developer Course – Week ONE

    At the beginning of July, I started a course on front-end web development taught by the Meta (Facebook) team on Coursera.

    It goes through 9 mini-courses in which it teaches you, from the introduction to how things on the Internet work to preparing for a coding interview over six months. I so far have completed the first 18-hour course and am working my way through Programming with Javascript (a 42-hour course)

    By the end, you earn a certificate from Meta, which covers the most popular web development (including the library React, which Meta developed for Javascript)

    The first course (Introduction to Front-End Development) introduced the core fundamentals of the Internet, how a server transfers info to a web browser, the most used languages, and basic HTML and CSS. It also discussed what to expect when beginning a programming career. It briefly covered how to incorporate libraries, what a Javascript framework is, how you’ll use it, etc.

    Compared to CodeCademy, it seems to be much more focused on what you should expect and prioritize what you would use in the real world. There is a lot more “in the field” of practical applications than the abstract way of teaching that Codecademy felt like, which focused on getting everything explained at once, instead of the way Meta prioritized the very basics and briefly introduced more complex topics that would be explained later when they’re needed.

    The course formatting usually goes like this:

    • Intro video to a concept (with examples of real-world use cases it can be used for)
    • a follow-up, more in-depth reading section (for example, an intro video to Javascript Arithmetic would be followed up with a reading section with every symbol variation and their use cases.)
    • In the next exercise, you will use the examples you previously learned in several specific case code snippets. (If you were learning how to use Arithmetic symbols, it would have you create a couple of different variations of equations based on what you learned before.)
    • Then, you have either a practice quiz or a quiz that reviews all the topics learned before, giving you examples of code snippets and asking you how they will be outputted.

    Module one of the second course (Programming with JavaScript) has taught me basic Javascript, such as for and while loops, fundamental variable assignment, arithmetic in Javascript, and if / else statements.