GithubHelp home page GithubHelp logo

rokoroku / react-redux-typescript-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
1.2K 35.0 371.0 1.73 MB

A bare minimum frontend boilerplate with React 16, Typescript 3 and Webpack 4

Home Page: https://rokoroku.github.io/react-redux-typescript-boilerplate

TypeScript 53.77% CSS 29.32% HTML 0.69% JavaScript 16.23%
react typescript boilerplate redux webpack postcss todomvc treeshaking

react-redux-typescript-boilerplate's Introduction

Frontend Boilerplate with React, Redux & TypeScript

A bare minimum react-hooks-redux-webpack-typescript boilerplate with TodoMVC example.

Note that this project does not include Server-Side Rendering, Static code analysis, Testing Frameworks If needed, please fork this repository and add your own that meets your requirements.

Ideal for creating React apps from the scratch.

Contains

Build tools

Installation

$ npm ci

Running

$ npm start

Build

$ npm run build

Deploy (to the GitHub Pages)

$ npm run deploy

License

MIT

react-redux-typescript-boilerplate's People

Contributors

alireza-mh avatar dependabot[bot] avatar drastus avatar erhangundogan avatar flying-sheep avatar jkowalik avatar machour avatar murbanowicz avatar rahulsmehta avatar rokoroku avatar sebtm avatar vguzev avatar wongteam avatar wtoa 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-redux-typescript-boilerplate's Issues

Nested routes

Hi, can you please provide an example of using nested routes? Thank you

Adding new route does not render the component

Could you please explain how to create new routes?

I'm trying with the following:

<Provider store={store}>
    <Router history={history}>
        <Route path="/" component={App}>
          <Route path="/new-route" component={Matrix} />
        </Route>
    </Router>
  </Provider>,

and then

<Link to="/new-route">New route</Link>

But it does not work. URL is changed, but content is not refreshed.

VSCode

How do I set up VSCode to debug with breakpoints?

Why no strictNullChecks?

I think it is better to switch this on by default (if possible). It's much easier to switch it off later, than to switch it on later.

It also forces us all to be honest about our typing discipline. Not having it on is a bit of a read flag, IMHO, when evaluating this project.

[Error] Type us not assignable to type...

Hello, first time transpiling I got this error:

ERROR in [at-loader] ./src/index.tsx:17:25
    TS2322: Type 'ComponentClass<{}>' is not assignable to type 'StatelessComponent<void | RouteComponentProps<any>> | ComponentClass<void |
 RouteComponentProps<a...'.
  Type 'ComponentClass<{}>' is not assignable to type 'ComponentClass<void | RouteComponentProps<any>>'.
    Type '{}' is not assignable to type 'void | RouteComponentProps<any>'.
      Type '{}' is not assignable to type 'RouteComponentProps<any>'.

ERROR in [at-loader] ./src/index.tsx:17:25
    TS2322: Type 'ComponentClass<{}>' is not assignable to type 'StatelessComponent<void | RouteComponentProps<any>> | ComponentClass<void |
 RouteComponentProps<a...'.
  Type 'ComponentClass<{}>' is not assignable to type 'ComponentClass<void | RouteComponentProps<any>>'.
    Type '{}' is not assignable to type 'void | RouteComponentProps<any>'.
      Type '{}' is not assignable to type 'RouteComponentProps<any>'.
        Property 'match' is missing in type '{}'

image

outdated dependencies

warning [email protected]: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
warning [email protected]: 🙌 Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
warning [email protected]: Package no longer supported. Contact [email protected] for more info.

warning "[email protected]" has incorrect peer dependency "babel-core@6".
warning "[email protected]" has incorrect peer dependency "ajv@^6.0.0".
warning "[email protected]" has incorrect peer dependency "caniuse-lite@^1.0.30000697".
warning "[email protected]" has incorrect peer dependency "redux@^3.1.0".

Install with yarn

when i run start the boilerplate, it take an error:

ERROR in /Users/twer/Desktop/jay/react-redux-typescript-boilerplate/src/main.tsx
./main.tsx
[tsl] ERROR in /Users/twer/Desktop/jay/react-redux-typescript-boilerplate/src/main.tsx(14,3)
TS2345: Argument of type 'Element' is not assignable to parameter of type 'ReactElement[]'.
Property 'includes' is missing in type 'Element'.
ℹ 「wdm」: Failed to compile.

how to resolve it?

IE error

image

I see errors when run in Internet Explorer (screenshot attached).
Appreciate any help.

Regards
Manohar

Typescript compilation failures

After cloning the repo at the current master, I'm seeing the following compilation issues:

node_modules/redux-devtools-extension/index.d.ts:1:32 - error TS2305: Module '"/data/tmp/redux-async-ts/node_modules/redux/index"' has no exported member 'GenericStoreEnhancer'.

1 import {Action, ActionCreator, GenericStoreEnhancer, compose} from "redux";
                                 ~~~~~~~~~~~~~~~~~~~~
types/global.d.ts:11:48 - error TS2344: Type 'keyof T' does not satisfy the constraint 'string'.
  Type 'string | number | symbol' is not assignable to type 'string'.
    Type 'number' is not assignable to type 'string'.

11 type Omit<T, K extends keyof T> = { [P in Diff<keyof T, K>]: T[P] };
                                                  ~~~~~~~

Steps:

  • Clone this repo
  • npm install
  • npx tsc

The second error appears to be related to known breaking changes in Typescript 2.9 with keyof. I'm assuming the first issue is just an out of sync typing file.

Downgrading to Typescript 2.8.4 got rid of the second issue.

IE

Hi, hot-reloading is not working in IE.
And also there is no TSX files under debug in IE.

Npm build not working

For me, npm build does not work. Initially I did not have webpack installed, so I thought this might be the problem, but even after installing webpack globally I still have the same problem.

run by docker

I cannot run this project by Docker. anyone tries to run inside of a docker?

[HOW] React Hot Loader integrating

This package is awesome!
I would like to apply React Hot Loader in my project. But I config same as you but still not working.
Tell me if I missing

webpack.config.js

// about plugins
// 1st Remove new webpack.HotModuleReplacementPlugin(),
// 2nd about devServer
devServer: {
	hot: true,
	inline: true,
},
 // 3rd about module
module: {
	rules: [
	//...
	{
		test: /\.(ts|tsx)?$/,
		include: appPath.appSrc,
		use: [
					{
						loader: 'babel-loader',
						options: { plugins: ['react-hot-loader/babel'] }
					},
					{
						loader: require.resolve('ts-loader'),
						options: {
							// disable type checker - we will use it in fork plugin
							transpileOnly: true,
						},
					},
				],
	},
],

App.js

// 4th import hot
export default hot<any>(module)(AppConfig)

Handling dots in path

I have issue to pass a param in path with dots inside it. I have a route (/mi/{token}) and when I am passing a token like 1.1 then WebPackDevServer can't handle the request.

I tried to use historyapifallback (https://webpack.js.org/configuration/dev-server/#devserver-historyapifallback), something like this:

historyApiFallback: {
      disableDotRule: true,
    },

or

historyApiFallback: {
      rewrites: [
        { from: /^\/mi/, to: 'index.html' }
      ]
    },

But it's not working for me. Is there any plugin or library that has conflict with that?
Thanks

Issue with router. It uses relative paths. Getting error: `expected expression, got '<'`

My routes work fine unless they are nested more than one level deep.

If I have this:

<Switch>
    <Route path="/rooms/:id" component={ShowRoom} />
    ...
</Switch>

I get errors on that page:

The script from “http://localhost:3000/rooms/b26a5036f70d782b55c3.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
d1e1eb23-80b3-4b62-af38-1baa520c1b3c
The script from “http://localhost:3000/rooms/vendor.b26a5036f70d782b55c3.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
d1e1eb23-80b3-4b62-af38-1baa520c1b3c
The script from “http://localhost:3000/rooms/app.b26a5036f70d782b55c3.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.
d1e1eb23-80b3-4b62-af38-1baa520c1b3c
SyntaxError: expected expression, got '<'
b26a5036f70d782b55c3.js:1
SyntaxError: expected expression, got '<'
vendor.b26a5036f70d782b55c3.js:1
SyntaxError: expected expression, got '<'

It looks like somewhere it's injecting the .js file as a relative path <... src="app.xxxxx.js">, instead of <... src="/app.xxxxxx.js">

I can't find where it is. Any help?

npm install error

Weird.

npm ERR! code 1
npm ERR! Command failed: /usr/local/bin/git clone --depth=1 -q -b Feature-getArgument git://github.com/ev1stensberg/generator.git /Users/usernamee/.npm/_cacache/tmp/git-clone-44a65de9
npm ERR! /Users/usernamee/.npm/_cacache/tmp/git-clone-44a65de9/.git: Permission denied
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/usernamee/.npm/_logs/2018-04-06T10_24_21_125Z-debug.log

I keep getting this error. This happens only on this repository. Other any repository works fine.

'history' has incorrect types

Cloning the project and running yarn install + yarn start will result in the following typescript error being thrown:

Module '"/Users/xtdbp/Playground/react-redux-typescript-boilerplate/node_modules/@types/history/index"' has no exported member 'createBrowserHistory'

By the looks of it, it's caused by an export mismatch between history and it's associated @types/history/

I'm pretty sure that the fix is to add the latest @types/history/ as dependency to package.json

Error while running code with yarn

I am getting this error when using yarn i.e. I did yarn install instead of npm install.
After npm start I am getting this error in terminal and browser console, although the app is running normally.

I tried tried this on node v6.9.2 and v7.9.0

[at-loader] ./src/components/MainSection/index.tsx:89:23 
    TS2322: Type '{ readonly addTodo: ActionFunctionAny<Action<TodoItemData>>; readonly editTodo: ActionFunctionAny...' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TodoItem> & Readonly<{ children?: ReactNode; }> & ...'.
  Property 'addTodo' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TodoItem> & Readonly<{ children?: ReactNode; }> & ...'.

PNG load error

When using somethign like this:

.logo {
background-image: url("server-icon.png");
}

I get this error

ERROR in ./~/css-loader?{"modules":true,"sourceMap":true,"importLoaders":1,"localIdentName":"[local]__[hash:base64:5]"}!./~/postcss-loader!./src/assets/logo.css
Module not found: Error: Can't resolve 'server-icon.png' in '/web/src/assets'
 @ ./~/css-loader?{"modules":true,"sourceMap":true,"importLoaders":1,"localIdentName":"[local]__[hash:base64:5]"}!./~/postcss-loader!./src/assets/logo.css 6:157-183
 @ ./src/assets/logo.css
 @ ./src/components/LogoFont.tsx
 @ ./src/components/index.tsx
 @ ./src/containers/Home.tsx
 @ ./src/index.tsx
 @ multi (webpack)-dev-server/client?http://localhost:3000 webpack/hot/dev-server ./index.tsx

unable to include css and js

whenever i add local script to index.html it shows Error: Parse Error

  • htmlparser.js:240 new HTMLParser
    [wt-hrm]/[html-minifier]/src/htmlparser.js:240:13

    • htmlminifier.js:966 minify
      [wt-hrm]/[html-minifier]/src/htmlminifier.js:966:3

    • htmlminifier.js:1326 Object.exports.minify
      [wt-hrm]/[html-minifier]/src/htmlminifier.js:1326:16

    • index.js:437 HtmlWebpackPlugin.postProcessHtml
      [wt-hrm]/[html-webpack-plugin]/index.js:437:34

    • index.js:270 Promise.all.then.then
      [wt-hrm]/[html-webpack-plugin]/index.js:270:25

    • next_tick.js:188 process._tickCallback
      internal/process/next_tick.js:188:7

Devtools

Inject redux-devtools into development build

RFC Typesrcript strictness

Hi, thank you for such a great boilerplate

What do you think about:

  1. Changing "noImplicitAny": false, to "noImplicitAny": true,. This will force users to use types as much as possible. We use your boilerplate for quite a big project and enabling this flag saved us many times (e.g. when mapStateToProps has no ownProps and return value types, it's impossible for compiler to understand if the component is properly initialized)

  2. Changing "noImplicitReturns": false, to "noImplicitReturns": true,. This just forces users to always have return value if function signature requires it, in each if()/ else() branches. I see no reason to keep it disabled

So the main idea of these 2 proposals is to require as more strictness as it is possible

Thank you

Implement linting & travis-ci

I think in general it would be good for people contributing to this repository as well as beginners using this boilerplate if there is some linting included e.g. ESLint or something like this.

If linting will be included, it would be great to also integrate travis, to automatically lint new pull-requests.

Add husky

since there is a prettier config in the project. Should I add husky to the project for only staged files?

Error in types/react-redux-d.ts

Cloned the repo, npm install, npm start and the following error is displayed in the console.

ERROR in [at-loader] ./types/react-redux.d.ts:11:18
    TS2314: Generic type 'MergeProps<TStateProps, TDispatchProps, TOwnProps, TMergedProps>' requires 4 type argument(s).

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.