My First Steps in React!


    React is probably the most common front-end JavaScript framework used in the industry today (at least among the job listings I've been looking at). The curriculum at Snow College is fairly heavily focused on the .NET stack, so I haven't had much of an opportunity to dig into JavaScript frameworks, but I want to learn, so I started building a simple application called 'Boop', which simply has a button you can click that changed from saying "Click Me" to "Boop" (as per my wife's request). This didn't take me too long, although I needed to figure out the best way to structure my App.js file. I used the base app that is create when you follow this simple tutorial, and I reused some the the CSS for simplicity.

    Since that really wasn't too bad after I built a constructor to handle state management, I decided I wanted to trying calling out to an API that would provide random quotes on my page. First I decided I would reach out to an API that provided random quotes from 'The Office', but I kept running into CORS issues. I found an API that offered random quotes from people in history, but it would only let me request 10 times an hour and I blew through those in only a few minutes of testing. Finally I found an API to provide random quotes from Donald Trump (I don't know how many of them are real), and for my purposes this worked great.

    After I found an API that would work correctly, everything else came fairly easily. I was able to make a fetch request to the endpoint which converted the result into Json. I even handled errors, which was helpful when ' The Office' API was returning unsuccessfully. The code is public on my GitHub, and you're welcome to check it out!

Comments

Popular posts from this blog

API's in C#

Using WebRTC to build a videophone in React and TypeScript

Reviewing WPF and MVVM