Skip to main content

props, state, and this. - stream-of-learning

As I look around the web for help understanding my troubles in React Native, I figure I'll just take notes as I go here, to document the process.

Right away, I learned something from this site (that I probably already saw someplace on the React Native documentation but it didn't stick):
"Components receive props from their parent. These props should not be modified inside the component."
This explains a lot. The line initializing player 1 looked like const player1 = new Player((name = "playa1"), (turn = true));. Setting the name with the props is fine, but setting "turn" with props doesn't make sense if props are immutable; turn needs to toggle from true to false repeatedly during normal Tic Tac Toe gameplay. This doesn't give me a solution but helps explain some of the problem.

I'm starting to wonder if turn should even be an attribute of the player at all. It might be easier to just have a global variable like "isPlayerOnesTurn" or something that just toggles. I think when I started, this was my plan, but somehow ended up going the player.turn route instead.

Still on I'm starting to feel like if I can understand what this sketch is doing, I'll be pretty close to my answer:

I can see that these .defaultProps() and .propTypes()

Another helpful bit here - I already knew "state" was mutable (that's what setState is for), but this site further clarifies that
State is internal to a component, while props are passed to a component.
This is good stuff. Still not answering my question about super(), but another great sketch here that I think I can use as a template for what I'm trying to do:

I'm calling it a night on Tic Tac Node for tonight, but feeling ready to get this thing working later this week!


Popular posts from this blog

Setting up an RStudio Server

I'm taking a break from React Native (our group decided not to use it for the Tic Tac Toe project) and wanted to put some thoughts in here about setting up my RStudio server for my SOTU-db project.

I won't get into the details of why I want the RStudio server here - that will be covered on the SOTU-db dev blog. Here, I just want to record some quick thoughts and problems that arose as I set up the server.  Gaining access to the server The server itself is a VM provided by Loyola University Chicago's Computer Science Department - thanks to George Thiruvathukal and Miao Ye for setting me up with this and providing support. 
I initially ran into issues because I couldn't figure out how to connect to the server. I knew I had been assigned a static IP and a DNS entry in Loyola's nameservers at, and assumed I would use SSH to connect to the server (which I further assumed was running Ubuntu in accordance with CS departmental policy and my previous expe…

New Position with Chicago Metro History Fair

I'm excited to have begun a new position at the Chicago History Museum a couple of weeks ago now. I am a "History Fair Program Specialist," meaning I help run the Chicago Metro History Fair.

The Chicago Metro History Fair (CMHF) is an annual, regional competition where middle and high school students in and around Chicago research a historical topic of their choice and create projects (exhibit boards, websites, documentaries...) that show off their hard work. Volunteer judges from around the community help provide feedback on the students' work, and winning entries can advance to state and national level competitions (administered by Illinois History Day and National History Day, respectively).

So far, my work has primarily been in preparing for weekend "Palooza" events, where volunteer coaches (often history teachers, faculty, graduate students, etc) and librarians assist students with their History Fair projects. The regional competition will take place i…

Setting up a Tomcat server

This post covers the process of setting up Apache Tomcat 9 as a server for static .html pages.
Environment & Background I have access to a VM running Ubuntu 18.04 on which I've already set up an instance of RStudio server. I have SSH access but not a graphical interface, so it's been a good opportunity to work on my Linux skills. My goal here was just to serve static HTML pages to site visitors for now. It's really satisfying to have full control over the HTML and CSS, instead of being in an environment like Wordpress (or Blogger!) where it's never quite clear what markup it will accept and what it will totally ignore. I've been mocking up a frontend for SOTU-db using W3-CSS, which feels like kind of a cross between traditional HTML/CSS/JS and React Native. 
I had played around with Ubuntu servers before, so I was familiar with Nginx and Tomcat. As I've said many times, my favorite part about Ubuntu is the documentation that is completely incomprehensible, …