Giter Site home page Giter Site logo

cedmax / react-with-typescript-starterkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from claudioc/react-with-typescript-starterkit

0.0 1.0 0.0 67 KB

Get started with React and TypeScript with this simple example project

License: MIT License

TypeScript 15.56% CSS 9.69% HTML 5.13% JavaScript 69.63%

react-with-typescript-starterkit's Introduction

React with TypeScript: a starter kit

This project puts together and gets you going with:

  • React and ReactDOM
  • TypeScript
  • CSS (with autoprefixer)
  • Webpack 2 (with hot module reload and web server)
  • Jest for testing
  • simple asset management

This project won't give you:

  • Application level state management (Redux or Mobx)
    • I'd like to consider this project a starter for people wanting to learn something new, and putting Redux (which you might not need) at this stage it'd be too much. Redux also somehow forces you to jump into containers while at the beginning it's already enough getting accustomed to components
  • A router
    • React Router 4 is much more than just a... router (you can "render" it, got it?) and before using it in a project is imho better if you take some time try learning how it actually works. Like Redux, RR is something which at the very beginning greatly removes the fun in the learning process and again, you might not need it
  • a TypeScript linter
    • because, again, you might or might not want to use it in the future in the way I use it
  • (rendered) component testing
    • this part would have needed another dependency and more configurations (AirBnB's Enzyme)
  • CSS modules
    • the modules are maybe at the moment the most common way to deal with CSS componentization and namespacing in React, but there are quite a few alternatives that you may consider before getting married to that technique. Take a look at Fela for example, or Styled Components and pick the best which suits your need
  • A proper production build
    • since this is a starter and getting stuff production ready is where opinions tend to diverge the most, I prefer to not add any optimization here. What you probably want to do in this case is to extract all the CSS in one file (Webpack's ExtractTextPlugin), compress the JavaScript (Webpack's UglifyJsPlugin) and give every asset a unique name (with some sort of hashing). Of course, you might want to get Critical too, and so on and so forth

This project is very little opinionated but still:

  • Uses standardjs for the code style
  • Puts the tests where they belong (together with modules or components) not in __tests__
  • Each components in its own directory, with the index.tsx containing logic and JSX, plus test as spec.js, (if any) and style.css
  • Uses a unprocessed index.css where you should put anything related to fonts definition and/or other CSS libraries imports which could give you some headache when trying to put them together in the webpack assets pipeline. The file is just moved in the right position as it is

Using it:

  • npm install
  • npm start will get you up and running on port http://localhost:3000
  • Edit or add anything and the project will be automatically build
  • If you want to run tests in watch mode, npm test -- --watch will do it
  • If you want to copy the "final" application somewhere, just run npm run build and then copy everything that's into /dist wherever you want

Known issues

  • When the web page reload itself on a change, sometimes the changes are not honored. In that case, nothing beats a Cmd+R
  • The index.css file doesn't trigger the live reload of the page (you shouldn't be editing this page too much anyway)

Aknowledgments and further readings

  • Thanks to @nickytonline for its starter project which gave me something to start with
  • Facebook's create-react-app which gave this project some ideas (and the CSS bits)
  • Here is another TypeScript starter from Microsoft which is based on create-react-app. It's own README is seriously worth reading

react-with-typescript-starterkit's People

Contributors

cedmax avatar claudioc 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.