davezuko / react-redux-starter-kit Goto Github PK
View Code? Open in Web Editor NEWGet started with React, Redux, and React-Router.
License: MIT License
Get started with React, Redux, and React-Router.
License: MIT License
Nice work! I've not a full experience with Redux, so i want to ask you, in your opinion what is the best way to integrate in this stack, Socket.io/websocket events to build components that manage real-time data?
As title says. Probably would be best to break the HomeView out into a HomeView + Counter component, and then demonstrate how to properly test smart vs. dumb components.
Need to make rules much more lenient since it's far too opinionated right now to be viable in a general starter kit.
A lot of examples and boilerplates, even the Redux official examples are not using .jsx for components.
Transition to this once all dependencies are verified to work with it.
Hot reload doesn't work again.
Investigate whether or not it is possible to define vendor dependencies by a regex. Currently there are some conflicts in names which lead to various issues (such as module resolution with react
and redux-devtools/lib/react
). Other issues, such as history
needing to be in the vendor bundle are also a bit perplexing, so figure out the best solution for avoiding these issues.
General question since I don't know how much people are even using this starter kit with non-JS assets (i.e. it's currently setup to allow Sass imports). Basically, do we want the focus of this starter kit to be strong support for client-side development, or should it be a more robust universal kit?
Benefit of going JS only
Downside of going JS only
I probably missed something somewhere, but those are my initial thoughts. Any other perspectives are greatly appreciated.
Every time I save a file, the entire page is reloading
Per title, ideas welcome.
Maybe in a public
or static
directory. This would be useful for things like favicons (or consider using React Helmet?).
How easy would it be to modify this boilerplate so it's not using koa, and simply becomes a boilerplate for react and redux?
So, usually a coding session of mine looks like the following:
However, with the very verbose setting of linting errors in the browser console, it's hiding most of my other debugging output. I've tried to disable the linting in the browser by commenting out the following part in build/webpack/client.js
:
//eslint : {
// configFile : paths.project('.eslintrc'),
// failOnError : globals.__PROD__
//}
But still I see the linting warnings/errors (that also sometimes stops me from continuing developing...).
How can I disable this?
I can't manage to see the redbox on error.
The console display an error and the page is refreshed.
I don't have any useful log and I don't know where to look to fix this, any idea ?
Hello! I was trying to deal with your starter kit. It works like a charm on Debian. But on Windows 7 (x64) small change makes the whole page to reload.
I realize this issue isn't strictly with the code and more a request for a total noob, but your were so prompt yesterday that you were the first person I thought to ask about this.
When I try adding a new component to the core layout I get errors. Here's what it all looks like:
Any idea what could be going on? Again, It's not really an issue with the code you wrote, it's just something I'm not grasping about the architecture of Redux (or the Flux philosophy)
after update till 0.14.0
there are problems.
In dev server warning:
Warning: React.findDOMNode is deprecated. Please use ReactDOM.findDOMNode from require('react-dom') instead.
In production.
npm run compile --production
npm run server:start
> [email protected] server:start react-redux-starter-kit
> node --harmony bin/server
fs.js:783
binding.stat(pathModule._makeLong(path), req);
^
TypeError: path must be a string
at TypeError (native)
at Object.fs.stat (fs.js:783:11)
at Object.<anonymous> (react-redux-starter-kit/consul/index.js:8:4)
at Module._compile (module.js:460:26)
at normalLoader (react-redux-starter-kit/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (react-redux-starter-kit/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
Hi, could you help with this?
I'm curious about your decision to embed your .spec
files in the /src
directory. I haven't used (or seen) this setup before. IMO it pollutes the source files. It is easy to change the config for a different setup, but I'd be curious as to why you prefer this approach.
Currently initial server state is entirely separate from what may be produced through initial application events (e.g. componentWillMount
). This is fine for basic state injections and store configuration, but ideally the server should be more closely tied to the application (especially for async actions initiated during the componentWillMount event).
Investigate solutions when time allows.
If I try to upgrade to the current version of react-redux, which is 0.5.3 from the version specified in package.json (0.2.2) then the sample app fails to start:
Uncaught TypeError: (0 , _reactRedux.provide) is not a function
The project contains a containers directory. Just to be clear, we speak about that kind of "containers".
https://medium.com/@learnreact/container-components-c0e67432e005
Also https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0
If yes, it could make sense to add it to the doc/readme. It would also helps understanding why there are different types of components/directories: views, containers and components.
That would also explains why it is nice to have styles and tests close to the component that is now dumb a easily reusable.
Would it not be better to know which one come from app ?
import React from 'react';
import { Provider } from 'react-redux';
import { Router } from 'react-router';
import routes from 'routes';
import invariant from 'invariant';
import { RoutingContext } from 'react-router';
import { createDevToolsWindow } from 'utils';
import { DevTools, LogMonitor, DebugPanel } from 'redux-devtools/lib/react';
vs
import React from 'react';
import { Provider } from 'react-redux';
import { Router } from 'react-router';
import routes from './routes';
import invariant from 'invariant';
import { RoutingContext } from 'react-router';
import { createDevToolsWindow } from './utils';
import { DevTools, LogMonitor, DebugPanel } from 'redux-devtools/lib/react';
I just completed development on an app, and have compiled it into a static build. the build folder contains a client and server folder. I'm new to node, so I have no idea how to run this compiled version and probably push it to heroku.
Please help. Thanks.
There have been a lot of changes to the starter kit recently, so the todo branch needs to be updated accordingly.
Can not start todo-example today.
Get error when run npm run dev:debug
:
ERROR in ./src/reducers/todos/index.js
Module build failed: TypeError: Cannot read property 'loc' of undefined
at getNodeIndent (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/rules/indent.js:112:49)
at EventEmitter.Program (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/rules/indent.js:547:45)
at EventEmitter.emit (events.js:129:20)
at Controller.controller.traverse.enter (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/eslint.js:815:25)
at Controller.__execute (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
at Controller.traverse (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/node_modules/estraverse/estraverse.js:495:28)
at EventEmitter.module.exports.api.verify (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/eslint.js:808:24)
at processText (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/cli-engine.js:199:27)
at CLIEngine.executeOnText (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint/lib/cli-engine.js:430:26)
at lint (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint-loader/index.js:26:20)
at Object.module.exports (/Users/nod/www/_nodejs/react-redux-todo/node_modules/eslint-loader/index.js:120:7)
@ ./src/reducers/index.js 11:13-31
Problem in [email protected]. With 1.2.1 works perfectly:
npm uninstall eslint
npm install [email protected]
npm run dev:debug
It seems more logical to me to put
client/entry-points/client.js
in client/main.js
client/entry-points/server.js
in server/main.js
What do you think ?
Btw, I made some folder restructuration (just for my own little project) because I prefer to work by modules/features, but this is purely opiniated. You can take a look here if you want.
I give you an example.
For a todo feature we have :
Voilà.
I stared at this for quite a while now but I can't figure out two things:
yield runRouter
but only location is passed in. In the server entry point I can see that Router.run is called and has a function as a parameter that takes initialState but how does thisnvariable ever get set to anything?Bonus question: Usually my routes would need to fetch data from APIs onEnter, how would I do this here so that it still works with server sode rendering (needs to wait until everything is fetched).
Do you manage to hot reload code ?
I updated my project today to reflect your changes and webpack is unable to hot reload.
[HMR] Cannot apply update. Need to do a full reload!
dev-server.js:19
[HMR] Error: Aborted because 198 is not accepted
To be sure, I cloned a fresh copy and had the same issue
Since updating Redux package versions to 2.0.0 there's an error (as reported by https://github.com/iamstarkov in 4c8f393).
"<Provider> does not support changing store on the fly. It is most likely that you see this error because you updated to Redux 2.x and React Redux 2.x which no longer hot reload reducers automatically. See https://github.com/rackt/react-redux/releases/tag/v2.0.0 for the migration instructions."
I got this error from the start, so probably with this deps-update source fore reducers also should be updated.
NODE_ENV=production npm run compile
npm run server:start
Gives the following error(s)
Error: Invariant Violation: Server-side <Router>s need location, branch, params, and components props. Try using Router.run to get all the props you need
I suppose it is related to remix-run/react-router#1455
I'm fairly new to webpack, but my understanding is you want it to serves up static assets and you would want a second server to handle other types of requests. For example if I want to fetch some data http:localhost:4000/users/1
When you run npm run dev
it doesn't appear that a second server is being spun up to handle these requests. How would you recommend setting this up in the starter kit ecosystem?
Thanks!
I've freshly clone the repo, ran npm install
and tried to run npm run dev
and get this error:
/home/devbox/dev/todo/build/webpack/client/index.js:49
sass-loader?includePaths[]=${projectConfig.inSrc('styles')}
^
SyntaxError: Unexpected token ILLEGAL
It appears node doesn't support string templates even with --harmony
flag. Perhaps I missed a step. I have node 0.12.7 installed via nvm running on ubuntu 14.04
Playing around with kit. I got this setup for routes :
<Route component={CoreLayout}>
<Route name='home' path='/' component={HomeView} />
<Route name='user-info' path='user' component={UsersView}>
<Route name='profile' path='user/:id' component={Profile} />
</Route>
<Route name='about' path='about' component={AboutView} />
<Route name='dashboard' path='dashboard' component={DashboardView} />
<Redirect from='admin' to='dashboard' />
</Route>
Nested routes like 'user/:id' , or even without params, just 'user/profile' doesn't work - error 404 =\
Tried different types of nesting, even without path with '/', like
<Route name='user-info' path='user' component={UsersView}>
// this should inherit the route, so its /user/profile
<Route name='profile' path=profiles' component={Profile} />
</Route>
, nothing works... Read through 1.0.0-beta3 docs many times, it seems like i'm doing everything right - but it doesn't work.
Can anyone figure out whats the problem?
Wrapping component UsersView renders {this.props.children}.
Everything installed just fine. I run other related react projects with no problem. Here's what happens when I run npm run dev
:
npm run dev
> [email protected] dev F:\_vms\HomesteadCode\_live\misc\react-redux-starter-kit
> node --harmony ./build/webpack-dev-server
net.js:633
throw new TypeError('invalid data');
^
TypeError: invalid data
at WriteStream.Socket.write (net.js:633:11)
at execFileSync (child_process.js:1364:20)
at Function.module.exports.sync (F:\_vms\HomesteadCode\_live\misc\react-redux-starter-kit\node_modules\yargs\node_modules\os-locale\index.js:78:16)
at Argv (F:\_vms\HomesteadCode\_live\misc\react-redux-starter-kit\node_modules\yargs\index.js:22:22)
at Object.<anonymous> (F:\_vms\HomesteadCode\_live\misc\react-redux-starter-kit\node_modules\yargs\index.js:10:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: `node --harmony ./build/webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script 'node --harmony ./build/webpack-dev-server'.
npm ERR! This is most likely a problem with the react-redux-starter-kit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node --harmony ./build/webpack-dev-server
npm ERR! You can get their info via:
npm ERR! npm owner ls react-redux-starter-kit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! F:\_vms\HomesteadCode\_live\misc\react-redux-starter-kit\npm-debug.log
I noticed that someone commented in another Issue that they are running this package without problems on Windows.
Now that @bulby97 has integrated react-catch-errors
, it would be nice to switch to redbox-react
once commissure/redbox-react#11 is resolved.
Hello
To learn node, webpack and react, I created my own starter kit based on yours. I started from scratch and slowly built it up into a fully working universal react router redux app :) I still don't understand everything, but I'm getting there. I have a problem with isomorphic-fetch though. I tested with my starter kit and also this one and the problem is the same.
Install isomorphic-fetch and json loader
npm install --save isomorphic-fetch json-loader
Add json loader to webpack config
module: {
preLoaders : [
{ test: /\.json$/, loader: 'json'}
],
When I run npm run compile I get this message
bojan@linux:~/www/react/redux-starter$ npm run compile
> [email protected] compile /home/bojan/www/react/redux-starter
> webpack
Container#eachAtRule is deprecated. Use Container#walkAtRules instead.
Container#eachRule is deprecated. Use Container#walkRules instead.
Container#eachDecl is deprecated. Use Container#walkDecls instead.
Node#style() is deprecated. Use Node#raw()
Container#remove is deprecated. Use Container#removeChild
Hash: 430e6819a630127bddb5093b040587334077bbc9
Version: webpack 1.12.1
Child client:
Hash: 430e6819a630127bddb5
Version: webpack 1.12.1
Time: 8379ms
Asset Size Chunks Chunk Names
app.430e6819a630127bddb5.js 731 kB 0 [emitted] app
vendor.430e6819a630127bddb5.js 2.73 MB 1 [emitted] vendor
app.660925c07cbbe319d4e37e587be37fa7.css 7.89 kB 0 [emitted] app
index.html 577 bytes [emitted]
[0] multi app 52 bytes {0} [built]
[0] multi vendor 100 bytes {1} [built]
+ 417 hidden modules
Child extract-text-webpack-plugin:
+ 2 hidden modules
Child server:
Hash: 093b040587334077bbc9
Version: webpack 1.12.1
Time: 7157ms
Asset Size Chunks Chunk Names
index.js 1.33 MB 0 [emitted] app
[0] multi app 28 bytes {0} [built]
+ 581 hidden modules
WARNING in ./~/isomorphic-fetch/~/node-fetch/~/encoding/lib/encoding.js
Critical dependencies:
9:12-34 the request of a dependency is an expression
@ ./~/isomorphic-fetch/~/node-fetch/~/encoding/lib/encoding.js 9:12-34
The funny thing is that the app works. But I want to get rid of this error or at least fully understand it. Any ideas?
Thanks for creating this repo. Could you move the todo example outside the starter kit? Having an example is very useful, but if you want to use this as a starter kit, you have to remove the todo example source code. If the example were in its own folder (or own repo) it would be a lot simpler to get up and running.
Thanks!
It's more a question than an issue, but is it actually possible to use this kit as a standalone module ?
Imagine that I'm building a website, and I want to use the react module in a div, something like :
<body>
<div id="reactmodule">
</div>
</body>
And in javascript
ReactDOM.render(node, document.getElementById('reactmodule'));
Is it normal ? Production vendor.js is heavier than developement vendor.js
I have been cutting my teeth on a variety of reactjs examples. I have successfully installed and can run this project on Windows! :) However when I update the line Welcome to the React Redux Starter Kit!
and save the file. Console shows module reloaded however, I have to reload the page to see the change. Is this normal? I have seen other projects where the change refreshed without reloading the page.
(sorry I'm on mobile, can't send a PR)
Hi
I try to update the example/todo-application to the current master and it works but I can not find out, how to modify the test.
In beforeEach when component is created with shallowRenderWithProps I try to pass the initialstate but it fails. The strange thing is that HomeView component is initialized with my props but the render method called for the second time with no props so it fails.
Any idea ?
When I change a file, the whole page reloads. Should the hot loader re-render without a full page refresh (and thus keeping the state)?
Per title.
I know in HomeView, two components are exported for the sake of unit testing. But you still can take advantage of ES7 decorators which IMHO will get us to a cleaner code on the long run in more complicated scenarios.
So instead of
export default connect(mapDispatchToProps)(HomeView);
create another class within the same file that inherits from HomeView but implements connect as a decorator. i.e.
@connect(mapDispatchToProps)
export default class ConnectedHomeView extends HomeView {
}
As export default is used anyway we won't have an issue with importing the connected one from the file
It is possible to reduce server bundle several times if we exclude from it node_modules (https://github.com/MrEfrem/react-redux-starter-kit/blob/master/build/webpack/server.js):
name : 'server',
target : 'node',
entry : {
app : [
paths.src('entry-points/server')
]
},
externals: fs.readdirSync('node_modules').filter(function(x) { return x !== '.bin' }),
...
And also I would clean UglifyJsPlugin from bundle, because differently in case of an error in stack trace it isn't clear where in bundle to look it.
And generally what sense in it for NodeJS to squeeze bundle?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.