Giter Club home page Giter Club logo

react-mobx-react-router4-boilerplate's Introduction

React MobX React-Router 4 Boilerplate

๐ŸŽ‰ React, React-Router@next, MobX and Webpack 2.

Just run npm install and npm start, then go to localhost:3000 to start developing. To build, run npm run build, and to preview run npm run preview, then go to localhost:1234 for the minified production bundle.

Async component loading

Components are now loaded async with react-router-loader and the store is injected via MobX Provider. If you've downloaded this boilerplate before remember to run npm install again.

Read this if you've been using an earlier version of this boilerplate

  • 05/03/17 - Hot reloadable MobX stores
  • 04/04/17 - Upgraded to React Router 4 @ latest
  • 01/31/17 - Upgraded to React Router 4 Beta
  • 01/28/17 - Routes are now loaded through Lazy-Route.

Todo

  • Async loading of components
  • Data fetching example
  • Protected Routes

react-mobx-react-router4-boilerplate's People

Contributors

aldarund avatar colshacol avatar devsli avatar mhaagens 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

react-mobx-react-router4-boilerplate's Issues

Question - not Issue - with rendering nested objects in SubItem

I apologize for the newbie question, but when I use a different endpoint in the aysnc call in the store it all works great, except for nested objects.

In SubItem
This works: {this.store.item.slug}
but this doesn't:
{this.store.item.title.rendered} <-- TypeError: Cannot read property 'rendered' of undefined(โ€ฆ)

Top level objects are fine, but not nested ones... How would I access the nested object without the undefined. I have googled this six different ways. Thanks!

Is this universal?

Just came upon your starter. Is this universal? I'm not seeing the usual server side code that I have seen with universal projects. Please advise. Thanks.

loeader-runner issue

Hi, just installed and started the app. Getting errors:

/react-mobx-react-router4-boilerplate/node_modules/loader-runner/lib/loadLoader.js:35
throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)");

npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]prestart: [email protected]
6 silly lifecycle [email protected]
prestart: no script for prestart, continuing
7 info lifecycle [email protected]start: [email protected]
8 verbose lifecycle [email protected]
start: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ankitkr/Desktop/NodeJS/react-mobx-react-router4-boilerplate/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle [email protected]
start: CWD: /Users/ankitkr/Desktop/NodeJS/react-mobx-react-router4-boilerplate
11 silly lifecycle [email protected]start: Args: [ '-c', 'node devserver.js' ]
12 silly lifecycle [email protected]
start: Returned: code: 1 signal: null
13 info lifecycle [email protected]~start: Failed to exec start script
14 verbose stack Error: [email protected] start: node devserver.js
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /Users/ankitkr/Desktop/NodeJS/react-mobx-react-router4-boilerplate
17 error Darwin 16.1.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
19 error node v7.2.0
20 error npm v3.10.9
21 error code ELIFECYCLE
22 error [email protected] start: node devserver.js
22 error Exit status 1
23 error Failed at the [email protected] start script 'node devserver.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the MartinsReactBoilerplate package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node devserver.js
23 error You can get information on how to open an issue for this project with:
23 error npm bugs MartinsReactBoilerplate
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls MartinsReactBoilerplate
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

fresh download of boilerplate fails to compile

I just checkout out a fresh copy of this, ran npm install and npm start. Here is the result of the npm start:

ERROR in ./src/components/App.js
Module not found: Error: Can't resolve './SubPage' in '{somewhere-in-my-home-dir}/react-mobx-react-router4-boilerplate/src/components'
@ ./src/components/App.js 74:79-98
@ ./src/index.js
@ multi react-hot-loader/patch babel-polyfill whatwg-fetch webpack-dev-server/client?http://localhost:3000 webpack/hot/only-dev-server ./src/index

Obviously the {somewhere-in-my-home-dir} part isn't literal, it was the absolute path in my home dir to the checked-out project.

I'm running node version v6.10.1 and npm version 3.10.10 on debian jessie.

Server Side Rendering

How would you achieve SSR through this approach, as there is no common routes file and using miss/match on routes? I'm confused

The UI not update when hot-reload #3

@mhaagens I am trying to make my own react starter project, and I really like yours, so use basically same configuration to yours. But Mobx hot-reload in my project. I know this is not your issue, but if possible, would you please help to check my config?

issue desc:

enviroment:

    "mobx": "^3.2.2",
    "mobx-react": "^4.2.2",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.1.2",
    "rfx-core": "^1.5.3"

entry:

.....
import "./stores" // init the store

const store = rehydrate()
ReactDOM.render(
  <AppContainer>
    <Router>
      <Provider store={isProduction ? store : hotRehydrate()}>
        <App />
      </Provider>
    </Router>
  </AppContainer>,
  document.getElementById('app'))

// hot reload config
if (module.hot) {
	module.hot.accept(() => renderApp(App))
}

@withRouter // make react-router work 
@inject('store')
@observer
export default class App extends Component {
  constructor(props) {
    super(props)
    this.store = this.props.store.appState
  }

  componentDidMount() {
    this.store.setDate('2017-11-11')
  }

  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={img} className="App-logo" alt="logo" />
          <h2>Welcome to React {this.store.dateStr}</h2>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload. {this.store.testVal}
        </p>
        ..........
    )
  }
}

Store:

export default class AppState {
  @observable testVal

  constructor() {
    this.testVal = '123'
  }
}

import { store } from 'rfx-core'

import AppState from './AppState'

export default store.setup({
  appState: AppState,
  ......
})

After updating Store, for example, change this.testVal = '123' to this.testVal = '1234', the log shows Store has changed, but the UI not updated.

image

Here is the sample project, would you please help to check?
https://github.com/njleonzhang/my-react-starter

Invariant Violation in Chrome and (all)

I am getting the Invariant Violation in

Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `App`.

I think the problem is in the dependencies that are specified imprecisely or really bleeding-edge.
Specifically, these:

 "devDependencies": {
   "extract-text-webpack-plugin": "^2.0.0-beta.4",
    "webpack": "beta",
    "webpack-dev-server": "^2.1.0-beta.8"
  },
  "dependencies": {
    "react-router": "next",
    "webpack-dev-server": "beta",
  }

Yarn complains that:

"dependencies" has dependency "webpack-dev-server" with range "beta" that collides with a dependency in "devDependencies" of the same name with version "^2.1.0-beta.8"

webpack and webpack-dev-server have a solid 2.2.0 release. Specifying it as just beta could be problematic. And react:router:next seems shaky too.

Trying to tweak these, then rm -rf node_modules && yarn, seems to have given me the broken build. The deps, as they are, seem a little brittle. I'm playing with it to see if I can make a more definitive suggestion.

How to use RouterStore

On some occasions I want to have an opportunity to push a route. Normally I would do it with injecting routing store. for example


@inject('routing') @observer
export default class Home extends Component {

  render() {
    let {routing} = this.props;
    return (
      <button onClick={()=>routing.push('/path/to/go')}>Push it</button>
    )
  }

But to have this work I have to configure it like this

import {Router} from "react-router-dom";
import createBrowserHistory from 'history/createBrowserHistory';
import {RouterStore, syncHistoryWithStore} from 'mobx-react-router';

const renderApp = () => {
  const browserHistory = createBrowserHistory();
  const routeStore = new RouterStore();
  const history = syncHistoryWithStore(browserHistory, routeStore);
  render(
    <AppContainer>
      <Provider store={store} routing={routeStore}>
        <Router history={history}>
          <App />
        </Router>
      </Provider>
    </AppContainer>,
    document.getElementById("root")
  );
};

I expect it work

 render() {
    let {routing} = this.props;
    return (
      <div >
        <Switch>
          <Route exact path="/" render={props => (
            <LazyRoute {...props} component={import("../pages/Home")}/>
          )}/>
         <Route exact path="/path/to/go" render={props => (
            <LazyRoute {...props} component={import("../pages/OtherPage")}/>
          )}/>
       </Switch>
     </div>
    )
}

Location change on address bar but OtherPage does not render until I do some thing like this:

 render() {
    let {routing} = this.props;
    return (
      <div >
        <span style={{display: 'none'}}>{routing.location.pathname}</span>
        <Switch>
          <Route exact path="/" render={props => (
            <LazyRoute {...props} component={import("../pages/Home")}/>
          )}/>
         <Route exact path="/path/to/go" render={props => (
            <LazyRoute {...props} component={import("../pages/OtherPage")}/>
          )}/>
       </Switch>
     </div>
    )
}

Am I doing something wrong? I feel I'm missing something

Access to posts url also when signed out

Thanks for this boilerplate! Only recognized this small bug:
When signed out and going to https://boilerplate.mhaagens.me/posts I'm automatically logged in again. Would be nice to see a very simple "login page" with maybe two buttons like "login success" and "login failure" and beeing redirected to posts after success.

But maybe I'm thinking already too far from a boilerplate code ;) Thanks for sharing this boilerplate!

Uncaught TypeError: Cannot assign to read only property 'render' of object '#<ProxyComponent>'

Hello, i'm getting the error below (browser console) after npm install & npm start. Can someone help me?

Uncaught TypeError: Cannot assign to read only property 'render' of object '#'
at ProxyComponent.componentWillMount (index.module.js:803)
at eval (ReactCompositeComponent.js:345)
at measureLifeCyclePerf (ReactCompositeComponent.js:73)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:344)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:255)
at Object.mountComponent (ReactReconciler.js:43)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:368)
at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:255)
at Object.mountComponent (ReactReconciler.js:43)
at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:368)

Thanks

Data fetch

Nice work. Where would you put the API calls going to the backend. In the store, the component or elsewhere?

RHL 3 and Webpack 2

According to the RHL 3 boilerplate example, this line shouldn't be necessary with webpack 2.0. Did you do it this way intentionally?

Just wondering because I attempted Webpack 2.0 and RHL 3 at one point and had a lot of trouble getting it working (the hot accept callback never fired).

Thanks for the demo!

Build error: Couldn't find preset "latest" relative to directory

I am not able to build. I hope you fix, because I LOVE everything else about this boilerplate, and plan to use it, if possible.

Install:

git clone xxx
cd react-mobx-react-router4-boilerplate
npm install
npm run build

Error:

ERROR in ./src/index.js
Module build failed: Error: Couldn't find preset "latest" relative to directory "/Users/hills120/dev"
    at /Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/options/option-manager.js:298:19
    at Array.map (native)
    at OptionManager.resolvePresets (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/options/option-manager.js:269:20)
    at OptionManager.mergePresets (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/options/option-manager.js:258:10)
    at OptionManager.mergeOptions (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/options/option-manager.js:243:14)
    at OptionManager.init (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/options/option-manager.js:373:12)
    at File.initOptions (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:221:65)
    at new File (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:141:24)
    at Pipeline.transform (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transpile (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-loader/index.js:38:20)
    at Object.module.exports (/Users/hills120/dev/react-mobx-react-router4-boilerplate/node_modules/babel-loader/index.js:131:12)
 @ multi babel-polyfill ./src/index

display images

Hello,
I would like to diplay images with a component
<Image name="logo.svg"/>
and i don't know wich path i can use.
How to load images with their paths/names ?

Thank you

UI wouldn't load; keep getting error: TypeError: this.context.router.createHref is not a function.

TypeError: this.context.router.createHref is not a function. (In 'this.context.router.createHref(typeof to === 'string' ? { pathname: to } : to)', 'this.context.router.createHref' is undefined)

The UI shows red background with the above message and then a ton of function names one after the other. I am new to React, MobX and even Javascript. Wanted to develop a website and thought this is the ideal project for me as I want to use MobX.
Cloned the repo and executed "npm install" and "npm start". Did not edit any code, so not sure why the error.
Please help!

New syntax for the image-file-loader in webpack2

After the first yarn start I got several warnings:

WARNING in ./src/images/react_logo.svg
(Emitted value instead of an instance of Error) DEPRECATED. Configure gifsicle's interlaced option in its own options. (gifsicle.interlaced)
@ ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/resolve-url-loader!./node_modules/sass-loader/lib/loader.js?sourceMap!./src/styles/main.scss 6:4940-4977
@ ./src/styles/main.scss
@ ./src/index.js
@ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-f......

I think you should update the loaders syntax in webpack 2 like so:


   test: /\.(gif|png|jpe?g|svg)$/i,
   use: [
      'file-loader', {
        loader: 'image-webpack-loader',
        options: {
          gifsicle: {
            interlaced: false,
          },
          optipng: {
            optimizationLevel: 7,
          },
          pngquant: {
            quality: '65-90',
            speed: 4
          },
          mozjpeg: {
            progressive: true,
            quality: 65
          },
          // Specifying webp here will create a WEBP version of your JPG/PNG images
          webp: {
            quality: 75
          }
        }
      }
    ]

There are two spell error in your porject.

It's a great start bolierplate. Personally I thought it's the best.
However the spell error in it is a little confused for a beginner like me.
app.js:45 Subitem should be SubItem
todo.js:4 Activelink should be ActiveLink
Anyway, thanks for sharing such a good boilerplate.

acitveName is not working

I just download your boilerplate and npm i -> npm start.

When I click Post navigation, not change header.

npm run build white screen fresh download

I've just downloaded this repository as a zip, ran npm install and npm start which works fine. When I visit 0.0.0.0:3000, which apparently is the default config, I see a site that is working perfectly fine.

However, when I run npm run build and open index.html in the dist folder, I'm presented with a white screen.
In my console I see 2 similar errors;
'Failed to load resource: net::ERR_FILE_NOT_FOUND'
Which is the same for vendor.e9ca13f16289d4c6444b.js and app.e9ca13f16289d4c6444b.js respectively.

npm run preview works fine, but I need these files on an apache server where I can't run that command.

Compile error

I got two errors while compiling:

ERROR in ./src/components/App.js
Module not found: Error: Can't resolve './SubPage' in '/home/cheon/Projects/react-mobx-react-router4-boilerplate/src/components'
 @ ./src/components/App.js 69:77-96
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-fetch ./src/index

ERROR in ./src/components/TopNav.js
Module not found: Error: Can't resolve './ui/Activelink' in '/home/cheon/Projects/react-mobx-react-router4-boilerplate/src/components'
 @ ./src/components/TopNav.js 14:0-41
 @ ./src/components/TopBar.js
 @ ./src/components/App.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-fetch ./src/index

Need to rename src/components/Subpage.js to src/components/SubPage.js.
And replace ./ui/Activelink in src/components/TopNav.js with ./ui/ActiveLink.

Router not working?

Seems like the router is not working properly when I run it local? Clicking the links in the top-bar will change the url, but it will not change the view.

This happens after fresh install, nothing changed other than a minor dependency issue (missing file-loader).

Am I missing something?

no such package available : @std/esm

On run npm install I receive this error:
npm ERR! 404 no such package available : @std/esm
npm ERR! 404
npm ERR! 404 '@std/esm' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'postcss-font-family-system-ui'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

upgrade react router to v4

after cloning the repo and installing the dependencies, running npm start results in an error that originates from react-router-dom 4.0.0-beta.3. ( this.context.router.createHref is not a function)

upgrading react-router-dom to 4.0.0 seems to fix it.

Licensing on this project and lazy route

@mhaagens First of all, thanks a lot for these projects.

Can you please let me know what licensing applies to this boilerplate and the LazyRoute project used by this? Would you be able to add the licensing terms to the projects?

Thanks in advance!

TypeError: this.context.router.createHref is not a function

The code for this app is currently broken out of the box.

I get this error after running npm install and then npm start:

image

TypeError: this.context.router.createHref is not a function
Link.render
webpack:///.//react-router-dom/Link.js?:72:36
eval
webpack:///./
/react-dom/lib/ReactCompositeComponent.js?:796:21
measureLifeCyclePerf
webpack:///.//react-dom/lib/ReactCompositeComponent.js?:75:12
ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext
webpack:///./
/react-dom/lib/ReactCompositeComponent.js?:795:25
ReactCompositeComponentWrapper._renderValidatedComponent
webpack:///.//react-dom/lib/ReactCompositeComponent.js?:822:32
ReactCompositeComponentWrapper.performInitialMount
webpack:///./
/react-dom/lib/ReactCompositeComponent.js?:362:30
ReactCompositeComponentWrapper.mountComponent
webpack:///.//react-dom/lib/ReactCompositeComponent.js?:258:21
Object.mountComponent
webpack:///./
/react-dom/lib/ReactReconciler.js?:46:35
ReactCompositeComponentWrapper.performInitialMount
webpack:///.//react-dom/lib/ReactCompositeComponent.js?:371:34
ReactCompositeComponentWrapper.mountComponent
webpack:///./
/react-dom/lib/ReactCompositeComponent.js?:258:21

Question: Has someone implemented Facebook login on top of this boilerplate?

Hi there folks! Has someone implemented Facebook (and/or Google, Twitter) login on top of this boilerplate and would you like to share the code changes as a different branch or something? I need to implement all the three logins for the Web App that I am creating. Have seen the login code outside of MobX (example: Facebook's own documentation of the Javascript API and PassportJS) but not sure how it can be integrated with MobX based apps. Any help with this will be much appreciated.

This maybe a silly question for experienced frontend developers out there. I am new to all the frontend technologies including Javascript, so please forgive my ignorance if this sounds too basic.

You may need an appropriate loader to handle this file type. (help)

I use your new configuration for my old application and I have this problem when I run " npm run start "

ERROR in ./src/index.js
Module parse failed: /media/youssouf/66AEA57AAEA54381/Work/editorv2/src/index.js Unexpected token (8:2)
You may need an appropriate loader to handle this file type.
| 
| ReactDOM.render(
|   <AppContainer>
|     <App />
|   `</AppContainer>,`

I update your config to be like this :

var path = require("path");
var webpack = require("webpack");
var precss = require("precss");
var autoprefixer = require("autoprefixer");
var HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    entry: [
        "react-hot-loader/patch",
        "babel-polyfill",
        "whatwg-fetch",
        "webpack-dev-server/client?http://localhost:8888",
        "webpack/hot/only-dev-server",
        "./src/index.js"
    ],
    resolve: {
        extensions: ['.js', '.jsx']
    },
    output: {
        path: path.join(__dirname, "dist"),
        publicPath: "/",
        filename: "app.[hash].js"
    },
    devtool: "eval",
    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                include: path.join(__dirname, "src"),
                loader: "babel-loader",
                query: {
                    presets: [
                        [
                            "es2015", {
                                modules: false
                            }
                        ],
                        "stage-0",
                        "react"
                    ],
                    plugins: [
                        "react-hot-loader/babel",
                        "transform-async-to-generator",
                        "transform-decorators-legacy",
                        'transform-class-properties',
                        'react-html-attrs',
                        'lodash', 
                        [
                            'lodash', {
                                'id': 'semantic-ui-react'
                            }
                        ]
                    ]
                }
            }, {
                test: /\.scss$/,
                loader: "style-loader!css-loader!postcss-loader!resolve-url-loader!sass-loader?sourceMap"
            }, {
                test: /\.(jpe?g|png|gif|svg)$/i,
                loaders: ["file-loader?hash=sha512&digest=hex&name=assets/images/[hash].[ext]", "image-webpack-loader?bypassOnDebug&optimizationLevel=7&interlaced=false"]
            }
        ]
    },
    plugins: [
        new webpack.NamedModulesPlugin(),
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({hash: false, template: "./src/index.html", title: 'PicsRush Photo Editor'}),
        //new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /nb/),
        new webpack.LoaderOptionsPlugin({
            test: /\.scss$/,
            debug: true,
            options: {
                postcss: function() {
                    return [precss, autoprefixer];
                },
                context: path.join(__dirname, "src"),
                output: {
                    path: path.join(__dirname, "dist")
                }
            }
        })
    ]
};
```

use Switch ๏ผŒ Component unchanging

react-route

<Switch>
<Route
    exact
    path={RoutePath.home}
    render={props => (
      <LazyRoute {...props} component={import("../components/home")} />
    )}
  />
<Route
  path={RoutePath.topics}
  render={props => (
    <LazyRoute {...props} component={import("../components/topics")} />
  )}
/>
<Route
  path={RoutePath.histtory}
  render={props => (
    <LazyRoute {...props} component={import("../components/history")} />
  )}
/>
<Route
  path={RoutePath.count}
  render={props => (
    <LazyRoute {...props} component={import("../components/count")} />
  )}
/>
<Route
  path={RoutePath.birds}
  render={props => (
    <LazyRoute {...props} component={import("../components/birds")} />
  )}
/>
<Route
  path={RoutePath.about}
  render={props => (
    <LazyRoute {...props} component={import("../components/about")} />
  )}
/>
<Route
    path={RoutePath.lazyRoute}
    render={props => (
      <LazyRoute {...props} component={import("../components/lazyRoute")} />
    )}
  />
<Route component={NotFound}/>
</Switch>

CSS loader

Create boillerplate! however I'm missing CSS loader, which comes in handy if you're importing some css from other libs. I can send PR.

Invariant violation in IE 11

After reading some of the documentation on the axios dependency I noticed that it doesn't appear to support IE 11, but when I load the demo I start getting invariant errors.

routes not loading in preview

In a production deployment... I ran npm run build, then npm run preview. I'm able to get to the site hosted at port 1234 (default ootb configuration in package.json). I'm able to navigate and go through posts and view an individual posts. But if I were to copy and paste that URL to a different browser, going to that page gives me a 404 not found. If I ran the project with npm run start I can use that same copied and pasted URL, and it would resolve to the proper post.

Is this a flaw with http-server or react-router? Or could it be the npm run build script and how the production code is being built? How would you recommend a local deployment of the production build that would allow for copied and pasted urls to work?

BTW, thanks for sharing the boilerplate, it was a great introduction to Mobx!

Recommended way to add multiple stores

Hi @mhaagens

Thanks for the awesome boilerplate!! I'm just wondering what would you recommend as the best way to add multiple stores. I've been reading issue #1 where you implemented the DataFetcher and I see that it relies on injecting the default store you setup @inject(['store']).

I'd like to fetch data for a different store but can't figure out the best way. I'm currently trying to pass through a store to the DataWrapper's @inject decorator but when I do the component then isn't passed through. Appreciate any help or tips you can offer :)

Thanks

error on git clone and npm install

ERROR in ./src/components/App.js
Module not found: Error: Can't resolve './SubPage' in '/home/paul/web/react-mobx-react-router4-boilerplate/src/components'
 @ ./src/components/App.js 69:77-96
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-fetch ./src/index

ERROR in ./src/components/TopNav.js
Module not found: Error: Can't resolve './ui/Activelink' in '/home/paul/web/react-mobx-react-router4-boilerplate/src/components'
 @ ./src/components/TopNav.js 14:0-41
 @ ./src/components/TopBar.js
 @ ./src/components/App.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-fetch ./src/index

made no changes.
on ubuntu 16.10
node v7.10
npm 5.3

Doesn't work with HashRouter

I used lots of your boilerplate, but the order in which the components are stacked don't work for me.
The components make the 's component context fail. I ended up switching the 2 components. So, first the and then the .

Lazy-Route import error

ERROR in ./src/components/App.js
Module not found: Error: Can't resolve './SubPage' in '/home/rechie/Developments/disaster-app-frontend/src/components'
 @ ./src/components/App.js 66:77-96
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server react-hot-loader/patch webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server babel-polyfill whatwg-fetch ./src/index

MobX warning in /posts

The /posts route throws this MobX warning in the console:

app.ce79ae9โ€ฆ.js:7 Mobx Observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'

Question - build error on Heroku

Not sure how to contact otherwise, so I write here. I'm using:

  "engines": {
    "node": "~6.3.1",
    "npm": "~3.10.8"
  }

both locally and on Heroku. Locally, everything builds and runs fine. On Heroku, I get following error while building:

       ERROR in ./src/components/App.jsx
       Module not found: Error: Can't resolve './Subitem' in '/tmp/build_5c5bda8dc1b617e85c8e685c9a8928b9/tomaash-mobx-babel-starter-f3dc48b/src/components'
       @ ./src/components/App.jsx 80:98-144
       @ ./src/index.jsx
       @ multi app

It seems that this line is suddenly causing a problem:

<Match exactly pattern='/' component={require('react-router?name=home!./Home')} />

I needed to turn off dynamic routing to be able to build successfully:

<Match exactly pattern='/' component={Home} />

I couldn't find anything about dynamic routing in react-router@next docs. Are there other ways to define it? Or did you encounter this issue and fixed it with some configuration?
Btw, this boilerplate is awesome. Great libraries, no-nonsense webpack config.

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.