Skip to content

Instantly share code, notes, and snippets.

@x1wins
Last active October 12, 2018 18:37
Show Gist options
  • Save x1wins/274ef44f1baadd5c83ddff1adf44487d to your computer and use it in GitHub Desktop.
Save x1wins/274ef44f1baadd5c83ddff1adf44487d to your computer and use it in GitHub Desktop.

install create-react-app

npm install -g create-react-app

confirm

npm list -g create-react-app
/usr/local/lib
└── [email protected]

build project

create-react-app crud-redux

install redux

npm install --save redux react-redux

material-ui

npm install material-ui --save
npm install --save-exact @babel/[email protected]
npm add @babel/runtime

restful api tutorial

axios

npm install axios -S

axios TypeError: Cannot read property 'setState' of undefined

The problem is not that the state doesn't exist, it is that you are not using the correct context for state.
You need to bind the axios callback function, otherwise this inside it will refer to its own context rather than that of the react component

change below code

.then(function (response) {

to

.then((response) => {

bootstrap

git clone https://github.com/creativetimofficial/light-bootstrap-dashboard-react.git
or 
git submodule add https://github.com/creativetimofficial/light-bootstrap-dashboard-react.git
  • Do use below $ yarn add GIT_URL
yarn add https://github.com/creativetimofficial/light-bootstrap-dashboard-react.git

$ vim package.json

{
  "name": "post-reactjs2",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "babel-eslint": "^9.0.0",
    "babel-jest": "23.6.0",
    "babel-loader": "^8.0.4",    
    "eslint": "5.6.0",
    "light-bootstrap-dashboard-react": "https://github.com/creativetimofficial/light-bootstrap-dashboard-react.git",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-scripts": "2.0.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}
rm -rf node_modules
yarn build
yarn start
$ npm install --save react-router-dom

router

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment