Code Monkey home page Code Monkey logo

nc-news-reacthooks-typescript's Introduction

A Front-end practice reference with React Hooks and Typescript.

This is a refactoring of the nc-news project (https://github.com/taodtu/nc-news-rest-client) with Reack hooks and Typescript, coupled with a back-end with serverless Azure functions and No-SQL Cosmos DB. In order to run this project locally, you need to have an Azure account and then start the backend project from (https://github.com/taodtu/nc-news-azure). A video demo for this project: https://youtu.be/Tsvn2WAThVE

Features

  • All class components are transformed into functional component and all components, functions, hooks are written with typescript. Generic is used to reuse function as much as possible.

  • Custome react hooks useFetch extract all data fetching logic which greatly simplify the component code and reusable, reduce any component needing data fetching logic up to 40 lines, and use union type to provide extra type safety.

  • Implement Context and useReducer to mimic a Redux like global store for comment to handle fetch, add and delete comments, which reduce the commentList component from 118 lines to 36 lines, and replace the original Render Props and Higher Order Component pattern.

  • Implement useRef to access PrepProps which is not available in current useEffect in order to rest papge to 1 when changing any other viewing options like sort and order.

  • All the data manipulations on array and object are ensured not mutating the original data by using destructuring and spread operator. In addtional to fullfilling the northcoder project requirement, an UserPage is created for more advanced functionality.

  • Maximize component reuse, such as the voting button, toggle-button, article list,comment-list, sort-select and handler functions.

  • Applying slot pattern and ContextAPI to pass the current user value to the bottom tree component, in order to avoid props drilling.

  • Implement optimistic response for the vote button.

  • Page-number style pagination implemented.

  • React 16 with create-react-app --typescript.

  • Responsive.

  • Styling with @material/ui v4.1.3.

  • Routing with @reach/router v1.1.0.

Installation

nc-news-reacthooks-typescript's People

Contributors

taodtu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.