Skip to content

The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.

License

Notifications You must be signed in to change notification settings

japfohl/react-typescript-samples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Typescript by sample

The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.

We have incorporated a set of examples based on hooks.

Right now you got two main folders:

  • Hooks: set of samples migrated to hooks (right now 11 samples migrated), if you are new to React, or you are going to start working on a new project, I recommend you going through these examples.

  • Old_class_components_samples: The old samples, just in case you need to work with older react versions or you need to maintain legacy code.

You can check as well other repos (react / redux + typescript):

Examples

The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript. Characteristics:

  • Bundling based on webpack.
  • React + Typescript based.
  • Simple navigation using react-router.
  • Managing async calls and updates.
  • Using Redux library (not available yet on hooks version, coming soon).
  • Handling async calls via Redux-Thunk + Redux Saga (not available yet on hooks version, coming soon)
  • Adding unit testing support (not available yet on hooks version, coming soon).
  • Implementing Lazy Loading (not available yet on hooks version, coming soon).
  • ...

To get started:

  1. Install NodeJS
  2. Download this repo
  3. Open the command line of your choice and cd to a sample directory within this repo on your machine
  4. npm install - Installs packages
  5. npm start - Builds the project and launch a lite web server (webpack-dev-server).
  6. Navigate to http://localhost:8080/ if your browser doesn't open automatically.

samples

Hooks

Bundling + npm start based on webpack.

Display the text 'Hello React'.

Hello world, simples react render sample.

Display the text 'Hello {name}' (where name is a prop that contains a given name).

Introduce a basic React concept, handling properties.

Starting from sample 02, Let's the user change the name to be displayed.

Introduce a basic React concept, handling State using hooks.

Starting from sample 03, let the user change the name only when he hits a change button.

Using callbacks.

Refactor sample 04, cleanup and discussion on where to place the state.

Refactor the job done.

Starting from sample 05, enable / disable the change button when the text is empty or same name as original name,.

Enable/disable components.

Simple color picker demo (show how properties work).

ColorPicker refactor.

Implementation of a single sidebar.

Render a table and use a child component to render each row, using mock data.

Starting from sample 10, remove mock data, hit a real REST API (Github api), use axios to perform the fetch call.

Old Class folder

00 Boiler plate

Bundling + npm start based on webpack.

01 Hello React

Hello world, simples react render sample.

02 Components

Creating a common header and about page react components.

03 Navigation

Creating a "members" page, adding navigation using react-router.

04 Display data

Create a read only list component (table >> tr >> td), reading list of members from a fake api and dumping it into component state.

05 Presentational Components

Breaking the list component into two: list and row compomenent, member row entity passed via props.

06 Handling asynchronous calls

Members fake api replaced with async call to api github to retrieve list of members of a given team.

07 Forms

In this sample we will add a link in the members page that will navigate to a "new member page". This new page will display a form where you have to enter the avatar url, login and id of a new member (just supossing we can edit that info).

08 ParamNavigation + Validations

Edit a given member, here we learn how to add params to a navigation link and how to obtain them from a component.

Validation performed so far:

  • Login: required, must be a string (at least length 3).

09 Redux

Added Redux support, isolated state into Redux reducers, implement load, save, basic validation cycle. This sample uses the fake api, in following samples we will call async operations and fitting them into Redux architecture.

10 SpinnerAsync

Display a busy indicator when an ajax request is in progress.

To have a global count of promises gong on we are using reat-promise-tracker and to display a cool spinner react-spinner

11 Testing reducers

Sample updated using Jest.

12 Testing actions

Sample updated using Jest.

13 Testing components (Containers and Presentationals)

Pending update Jest + Enzyme

14 Replacing Redux Thunk with Redux Saga

Pending update

15 Lazy Loading and React-Router

Pending update

16 Add custom middlewares

Pending update

17 Add support for ReactHotloader and ReduxDev Tools.

Pending update

18 Hooks

Replace class components by stateless components using Hooks.

19 LoginForm

Add a login page using Material-UI.

Contributors

Special thanks to Jehu Sagardoy for his contributions checking and getting uptodate examples.

About Basefactor + Lemoncode

We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.

Basefactor, consultancy by Lemoncode provides consultancy and coaching services.

Lemoncode provides training services.

For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend

About

The goal of this project is to provide a set of simple samples, providing and step by step guide to start working with React and Typescript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 86.5%
  • JavaScript 10.3%
  • CSS 2.3%
  • HTML 0.9%