Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 27, 2020 04:01 am GMT

Live Coding Pairing: Converting a Preact Component to use hooks

A few weeks ago, I wrote a post asking DEV community members if they wanted to potentially pair program with me during a live coding session.

A lot of interest was generated and so we did our first live coding pairing session that was streamed on doingdevfordev.com. It was with DEV community member Sophia Li.

.ltag__user__id__215107 .follow-action-button { background-color: #d7dee2 !important; color: #022235 !important; border-color: #d7dee2 !important; }
sophia_wyl image

She worked on the <ImageUploader /> Preact component in the DEV/forem codebase. It was originally a class component that she converted to a function component using the useState hook.

For the full recording of the pairing session check out the YouTube video below. Also, feel free to subscribe to my channel.

Near the end of the pairing session we discussed the possibility of using the useReducer hook instead. After the pairing session, Sophia continued working on the PR she created and implemented the necessary changes to use the useReducer hook.

For those interested, here is the merged PR.

GitHub logo Update `<ImageUploader />` class component to use hooks #9369

What type of PR is this? (check all applicable)

  • [x] Refactor
  • [ ] Feature
  • [ ] Bug Fix
  • [ ] Optimization
  • [ ] Documentation Update

Description

This PR refactors the <ImageUploader /> class component to a function component using the useReducer hook.

Related Tickets & Documents

#9338

QA Instructions, Screenshots, Recordings

Screen Shot 2020-07-25 at 4 10 02 PM

No new features were added, so we did not add new tests. All previous tests pass. The component works the same as before.

Added tests?

  • [ ] yes
  • [x] no, because they aren't needed
  • [ ] no, because I need help

Added to documentation?

  • [ ] docs.dev.to
  • [ ] readme
  • [x] no documentation needed

[optional] Are there any post deployment tasks we need to perform?

No

[optional] What gif best describes this PR or how it makes you feel?

excited woman dancing and celebrating

It was awesome pairing with Sophia and by the way, shes looking for her next role!

Looking forward to the next pairing session!


Original Link: https://dev.to/nickytonline/live-coding-pairing-converting-a-preact-component-to-use-hooks-75e

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To