Continuing Education in React-Graphql-Redwood.js

Continuing Education in React-Graphql-Redwood.js

Setting up a React project with create-react-app

Use styled components. Use Prettier.js to keep code consistent. Remove unnecessary files after running Create React App as soon as possible. It's important to have well defined file structures and folder structures sooner rather than later in a project, i.e. layouts folder for major view outlines for common components rendered on every view or multiple views have shared components.

Use a components folder for lower level stuff. A views folder for higher level stuff. __tests__ for tests. App.js and index.js remain at root level of the folder. React.StrictMode gives you a layer of (assurance)[https://reactjs.org/docs/strict-mode.html], but it does introduce complications when developing locally.

Add files to .gitignore. Make skeleton components by adding empty files where you think you might need them. Having a high level idea of your views reinforces the structure of your files and folders.

Building Your React App's Architecture

Use semantic html where possible -- not every component has to be wrapped in a div. Fill out logic of skeleton files by wiring together components.

Making Skeleton Components In Your React App

Use Material UI for forms as it's easy to implement and powerful.

Adding Routing in React with react-router-dom

Add routes in the App component using React Router Dom. Store routes in Routes.js file. Switch component allows routes to be rendered exclusively. Typically, the exact attribute is used in Route components. Include slashes in slugs, eg. ` Organize import statements in alphabetical order for quick skimming. Replace all <a href> components with components from React Router Dom, eg. <Link to> Higher level styled components should be named so you can keep track of where you are in the application -- lower level styled components can be anonymous. Styled components are typically declared as const and occasionally declared as function.

Adding Styles And Hooks To Components

Use mock data to aid development. Instead of Redux, use createContext. Context captures data and can be shared across multiple components, especially for global values used across the app, to avoid deep prop drilling. useState is how to handle form updates, actions on the page, and other dynamic interactions that happens in an SPA. Any components wrapped inside a provider has access to context functions

Working With Third-Party APIs and Data Handling

fakerapi.it is a free API that serves mock data although you can't POST to it. useEffect pulls data when the component loads, and adding an empty array as an argument, the call only happens once to avoid an infinite loop, eg. useEffect(handler, []); Define dependencies of component function below the function in the same file

Finishing Up APIs And A Bit About Packages

Styled components can target child components. Talk through your thinking process when debugging; it also helps to refresh the browser. Use trial-and-error to figure out which libraries to use. Make sure libraries are relatively small. Libraries used should have good documentation. Libraries should have a community that will maintain it. When's the last pull request? When's the last time a user asked a question about the library on Stack Overflow? As a last resort, look at number of stars on the repo in GitHub

Performance Optimization and Accessibility In React

Code split so components are lazy loaded instead of loading all components up front, slowing down load time. Use React's Suspense to load placeholder elements. React.lazy allows you to render a dynamic import as a regular component to dynamically load all components. Much of the code splitting can be done in the router, which is where components are loaded from. Split larger components as it might not make a huge difference to code split smaller components. Use profiler tab in dev tools to record how long each component takes to load. Use Lighthouse tool to generate a report for your app. Everyone deserves the same level of access.

Writing Tests For React Components

There are many ways to write tests. Read test reports to understand what to repair. Testing can be tricky because certain packages aren't up-to-date with what's happening in the testing library, which means things are out of sync.

Writing A Test For Fetching Data From an API

Use mock requests and mock data to see if components render the way we expect. Use skeleton test to try out broad ideas to get some direction early in a project or feature

React-Graphql-Redwood.js































要查看或添加评论,请登录

Valerie Blackburn的更多文章

  • 200OK Web Conference

    200OK Web Conference

    Here is a summary of the presentations. Data Warehouses from an app developers perspective.

  • Learning about Azure software

    Learning about Azure software

    An Azure region is a set of datacenters deployed within an interval-defined perimeter and connected through a dedicated…

  • Google Data Cloud Summit

    Google Data Cloud Summit

    Cross-cloud analytics and visualization with BigQuery Omni and Looker When viewing the google Data Cloud Summit…

  • How to Create a Résume in Code

    How to Create a Résume in Code

    When viewing a pdf version of my résume on the website, I realized the quality was compromised. Considering that I was…

  • UX Design - Artist Sales Application

    UX Design - Artist Sales Application

    This UserExperience design project began as part of the Google UX Design certification course. The Goal = To design an…

  • Adobe MAX Conference

    Adobe MAX Conference

    This conference provided a front row seat to the latest Adobe products, features, and innovations. See how, together…

  • Google "User Experience (UX) Design" course

    Google "User Experience (UX) Design" course

    To quote the course, "In the 1990's, Don Norman, a cognitive psychologist, coined the term User Experience." The…

  • Wordcamp Europe 2021

    Wordcamp Europe 2021

    Day 1 Track 1: Lesley Molecke and Jose Ramon Padron (Global Lead WCEU) How Agile WordPress project management helps in…

  • OKC Coders course in React-Angular.js-Redwood.js

    OKC Coders course in React-Angular.js-Redwood.js

    Here is the information learned in the class. This course was completed on December 15, 2020.

  • How to advertise on Google

    How to advertise on Google

    Your client needs web site traffic growth. You've tried social media posts, word of mouth and advanced Search Engine…

社区洞察

其他会员也浏览了