What I Googled Today (WIGT) #1

I need to get back to writing regularly. Ages ago I wiped all my blog posts so I could start fresh and then…didn’t. I figure the easiest way to get started is just start sharing what I have to google every day. It’ll help me build a habit, create a ref…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by mariel

I need to get back to writing regularly. Ages ago I wiped all my blog posts so I could start fresh and then…didn’t. I figure the easiest way to get started is just start sharing what I have to google every day. It’ll help me build a habit, create a reference for Future Me, and serve as further evidence that being a software engineer is in part being a Professional Google Searcher. Here we go.

How to make comments in JSX?

Answer: When you’re inside a JSX block — so, for example, below a <div> and above a <button> — you use: {/* comments here/*}

Reference: Babel, JSX, and Build Steps – React (reactjs.org)

How I got here: I’m working through Epic React by Kent C. Dodds (which is great, by the way) and I needed to leave myself some notes. There are a lot of different opinions about how to comment your code and when, but when I’m learning something new on my own I’m very pro “comment directly in your file”. It helps me make sure I can explain what’s happening and gives me a reference when I come back and don’t remember what I was doing.

Why event prevent default?

Answer: Using event.preventDefault() keeps the browser from executing the default behavior of the event being triggered by a user’s actions (e.g. clicking on the submit button in a form). We commonly use it in forms so we can validate input in some way before submitting.

Reference:

How I got here: Working on an exercise about forms in React, we needed to make an event handler. Using .preventDefault is something I’ve done plenty of times but had never bothered to look up to learn about how it works or why.

Use State Hook

Answer: Per the React docs: “Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class,” and “useState is a Hook that lets you add React state to function components.”

Reference: Using the State Hook – React (reactjs.org)

How I got here: That’s it, that’s all I googled: “use state hook”. Hooks were mentioned in the exercise I was working on and I wanted to read more about the one we were using.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by mariel


Print Share Comment Cite Upload Translate Updates
APA

mariel | Sciencx (2023-01-05T18:59:21+00:00) What I Googled Today (WIGT) #1. Retrieved from https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/

MLA
" » What I Googled Today (WIGT) #1." mariel | Sciencx - Thursday January 5, 2023, https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/
HARVARD
mariel | Sciencx Thursday January 5, 2023 » What I Googled Today (WIGT) #1., viewed ,<https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/>
VANCOUVER
mariel | Sciencx - » What I Googled Today (WIGT) #1. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/
CHICAGO
" » What I Googled Today (WIGT) #1." mariel | Sciencx - Accessed . https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/
IEEE
" » What I Googled Today (WIGT) #1." mariel | Sciencx [Online]. Available: https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/. [Accessed: ]
rf:citation
» What I Googled Today (WIGT) #1 | mariel | Sciencx | https://www.scien.cx/2023/01/05/what-i-googled-today-wigt-1/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.