Giter VIP home page Giter VIP logo

full-stack-react-typescript-and-node's Introduction

Full-Stack React, TypeScript, and Node

Full-Stack React 17, TypeScript, and Node

This is the code repository for Full-Stack React 17, TypeScript, and Node, published by Packt.

Build cloud-ready web applications using React 17 with Hooks and GraphQL

What is this book about?

This book takes a hands-on approach to implementing modern web technologies and the associated methodologies for building full-stack apps. You’ll begin by gaining a strong understanding of TypeScript and how to use it to build high-quality web apps. The chapters that follow delve into client-side development with React using the new Hooks API and Redux. Next, you’ll get to grips with server-side development with Express, including authentication with Redis-based sessions and accessing databases with TypeORM. The book will then show you how to use Apollo GraphQL to build web services for your full-stack app. Later, you’ll learn how to build GraphQL schemas and integrate them with React using Hooks. Finally, you’ll focus on how to deploy your application onto an NGINX server using the AWS cloud. By the end of this book, you’ll be able to build and deploy complete high-performance web applications using React, Node, and GraphQL.

This book covers the following exciting features:

  • Discover TypeScript’s most important features and how they can be used to improve code quality and maintainability
  • Understand what React Hooks are and how to build React apps using them
  • Implement state management for your React app using Redux
  • Set up an Express project with TypeScript and GraphQL from scratch
  • Build a fully functional online forum app using React and GraphQL
  • Add authentication to your web app using Redis
  • Save and retrieve data from a Postgres database using TypeORM
  • Configure NGINX on the AWS cloud to deploy and serve your apps

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

if (test expression)
{
  Statement upon condition is true
}

Following is what you need for this book: The book is for web developers who want to go beyond front-end web development and enter the world of full-stack web development by learning about modern web technologies and how they come together. A good understanding of JavaScript programming is required before getting started with this web development book.

With the following software and hardware list you can run all code files present in the book (Chapter 1-17)

Software and Hardware List

Chapter Software required OS required
1 to 17 React 17 Windows, Mac OS X, and Linux (Any)
1 to 17 Node 12 or greater with npm Windows, Mac OS X, and Linux (Any)
1 to 17 TypeScript 3.7 or greater Windows, Mac OS X, and Linux (Any)
1 to 17 A modern web browser: Chrome, Safari or Firefox Windows, Mac OS X, and Linux (Any)

Related products

Errata

  • Page 18 (bullet point 7): npm install typescript should be npm install -g typescript

Get to Know the Author

David Choi is a developer with over 10 years' experience in building enterprise-class applications using a variety of frameworks and languages. Most of his professional development experience has involved working in finance for companies such as JPMorgan, CSFB, and Franklin Templeton. He currently works at his own start-up, DzHaven, building an application to help devs help other devs. You can find David on YouTube at the David Choi channel, or on Twitter at jsoneaday.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781839219931

full-stack-react-typescript-and-node's People

Contributors

deepesh-packt avatar divyavijayan123 avatar dzadmin avatar jsoneaday avatar packt-itservice avatar packtutkarshr avatar saurabhk710 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

full-stack-react-typescript-and-node's Issues

Example code in chap4 breaks with react-router-dom > v5.2

The example code in chap4 breaks with react-router-dom > @v5.2

The Switch component is no longer available and the compilation complains about this

Attempted import error: 'Switch' is not exported from 'react-router' (imported as 'Switch').

Clarification on Chapter 3 for the this keyword

Hello everyone. I am the author of the book and wanted to clarify an item in Chapter 3. I gave an explanation about this that is very sparse and not really useful. So here's a somewhat more fleshed out example. Please look at the code below.

`globalThis.label = "outside";

function MyFunction() {
if (!this.label) this.label = "inside";
console.log("from function " + this.label);
}

MyFunction();
let test = new MyFunction();`

Firstly because we were using Node and not a browser the root object is not window but the Node Global Object called globalThis (or just global if you're not using TypeScript). Here's a rundown of what this code is doing.

  1. In this code we first set a property of the globalThis object called label to the value "outside" to indicate where this property was set.
  2. Subsequently we define a new function called MyFunction and inside it we first check for the this object's label property and set it to "inside" if it has no value.
  3. Then we console.log the this.label's value.
  4. And then finally we use the function in two ways: first we call it directly as a function and next we create an object instance called test by using the new keyword (which means we use the function as a constructor).

If you run this code you'll see that the first console message shows "from function outside" and the second shows "from function inside". A couple of points on this result.

  1. The first result is happening because we are directly calling the function as a function, as opposed to instantiating it as an object. Therefore the internal this is the globalThis Node object. And therefore the resulting label value is "outside"
  2. However in the second line we are instantiating the MyFunction as an object. Therefore the function's internal this is the test variable. And since the test variable was newly declared it would not have a value for label and therefore the label is set to "inside" and displayed as such.

Now just one final point. If in the MyFunction definition, just above the console.log statement, you were to add the line let label = "neither" it would not affect the results of the console.log at all. You may already be aware of why this is the case, but the reason why it does not affect the result is that the let label statement is creating a new variable as part of the function scope--not the this keyword. In other words the squiggly brackets indicate the lifetime of variables within the brackets and not the members of the this object instance.

I hope this is a better explanation.

Chapter 2: problem with interface in functionGeneric.ts

Hi there.

I don't know if this problem only appears to me, but I would like to comment it anyway...

In functionGeneric.ts in chapter 2 the concept of generics is introduced. The first half of the code is introduced like this:

function getLength<T>(arg: T): number {
  if(arg.hasOwnProperty("length")) {
    return arg["length"];
  }
  return 0;
}

console.log(getLength<number>(22));
console.log(getLength("Hello world."));

So far so good.

But in the second part, when I have commented all the previous code as instructed and enter the following one...

interface HasLength {
  length: number;
}

function getLength<T extends HasLength>(arg: T): number {
  return arg.length;
}

console.log(getLength<number>(22));
console.log(getLength("Hello world."));

... then I get this error:

Type 'number' does not satisfy the constraint 'HasLength'. ts(2344)

Maybe I'm guessing but.... Is it possible that some change during Typescript 3.8 makes it impossible to implement an interface in this way now? Or maybe I'm missing something?

By the way, I'm using VScode in Linux Mint 20.1 with Typescript v3.8.3 and node v14.16.1 installed globally (both).

Chapter 6: Mocking with jest.fn

Dear Author,
In Chapter 6: Mocking with jest.fn I think it is better to update the snippet with the following:

return userByName ? userByName.name : "Unknown name";

Otherwise when it renders the HTML shows [Objec object] for known names and undefined for unknowns.

A total number of 6 errors in the RichEditor.tsx file

I 'am currently stuck at chapter 12 with this huge number of errors and because of my limited knowledge about slate and overall typescript I couldn't fix any of them so I'll appreciate some help and I'm sure this will help other future readers.

P.S: I didn't edit one line of code from how it is in the repo.

screenshot's :
image
image
image
image
image
image
source code from the repo

Chapter 6: DisplayText type void not assignable to Button element

/Users/daz/Code/_learn/fullstack-react-typescript-node/06/ejected-app/src/DisplayText.tsx
TypeScript error in /Users/daz/Code/_learn/fullstack-react-typescript-node/06/ejected-app/src/DisplayText.tsx(46,44):
Type '(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void' is not assignable to type 'MouseEventHandler<HTMLButtonElement>'.
  Types of parameters 'e' and 'event' are incompatible.
    Type 'MouseEvent<HTMLButtonElement, MouseEvent>' is not assignable to type 'MouseEvent<HTMLButtonElement, MouseEvent<Element, MouseEvent>>'.
      Type 'MouseEvent' is missing the following properties from type 'MouseEvent<Element, MouseEvent>': nativeEvent, isDefaultPrevented, isPropagationStopped, persist  TS2322

    44 | 
    45 |       <div>
  > 46 |         <button data-testid="input-submit" onClick={onClickShowMsg}>
       |                                            ^
    47 |           Show Message
    48 |         </button>
    49 |       </div>

Hi, I encountered the above error, while following the page 184 example verbatim.

Managed to resolve it, thanks to this answer, but don't understand why {onClickShowMsg as any} is required. Could I get further guidance or a pointer to documentation for this?

Many thanks in advance.

Node version

This project is incompatible with the latest version of node.

I had to target node version 16 to get chapter 4 to work. Please update read.me.

Chapter 8 page 283 Express Node

Working on the expressapp.mjs :
The CURL command for the terminal is not working anymore.

we set up all the middleware -> then we set up a route object and set up the middleware routes -> then we want to test our POST method with curl, but its not working as intended.

This is the curl code we should use:

curl --header "Content-Type: application/json" --request POST
 --data `{"userid":"1","message":"hello"}` "http://localhost:8000/c"

this error message in the terminal output:

userid:1: command not found
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information

note: im running my express Node server on another terminal. The CURL worked for a previous section of the chapter where I also had to test a POST url request.

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.