Giter Site home page Giter Site logo

sorejmar / react-typescript-samples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lemoncode/react-typescript-samples

0.0 1.0 0.0 314 KB

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: MIT License

CSS 1.96% HTML 0.99% TypeScript 87.78% JavaScript 9.28%

react-typescript-samples's Introduction

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. Characteristics:

  • Bundling based on webpack.
  • React + Typescript based.
  • Simple navigation using react-router.
  • Managing async calls and updates.
  • Future enhancements:
  • Form validation.
  • More advanced navigation scenarios.
  • Redux samples.

Contributors and reviewers are more than welcome.

##To get started:

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

##IDE: We have tested in:

samples

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 + Validations

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).

Validation performed so far:

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

TODO, add this validations:

  • Id: required, must be a number.
  • Avatar URL: optional, must be a valid url.

08 Edit member

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

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 Redux Thunk - Handling Asyhcronous calls

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

Similar to sample 06, but this time we implement this functionallity fitting it in Redux, Redux-Thunk middleware.

11 Spinner

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

We have created here:

  • A component that will take care of showing / displaying the busy indicator (spinner).
  • A reducer that will take care of dispatching http requests in progress / completed.
  • A http helper that will wrap the request to trigger the proper messages (new request, request completed...), just to have a single entry point for this.

We have updated MemberAPI to use the http helper / wrapper.

12 Testing reducers

Testing libraries:

We added a Karma configuration on Webpack, that runs every '.spec' inside src folder and subfolders. This configuration allows debugging with Typescript.

With Mocha we can describe our tests and it adds support for async tests.

Chai is for assertions.

With Deep free we ensures that initial states in reducers are immutable.

13 Testing actions

Testing libraries, previous libraries and:

Sinon join Mocha allow us async action tests.

14 Testing components (Containers and Presentationals)

Testing libraries, previous libraries and:

Enzyme provide an easy way to isolate, manipulate, traverse and assert React Components.

react-typescript-samples's People

Contributors

nasdan avatar brauliodiez avatar antoniogiroz avatar josemigallas avatar

Watchers

 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.