RadioGroupButton doesn't seem to work with React Starter Kit - reactjs

Here's a gif of it:
http://www.giphy.com/gifs/3oKIP7arhKhNzNzytq
As you can see, whenever I click on it, it doesn't select.
Here's my exact code which is working in webpack:
https://www.webpackbin.com/bins/-KoaaPYxDno695fiUBMn
But in my starter kit environment, it doesn't seem to work. However, checkboxes seem to work. Any ideas?
"react": "^15.5.4",
"react-dom": "^15.5.4",
"material-ui": "^0.18.6",
EDIT: I also have react-tap-event-plugin and I've called it at the top of my client.js file. Also tried on the top of my Location.js file.
import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();
Here's my full dependency list:
dependencies": {
"apisauce": "^0.14.0",
"babel-polyfill": "^6.23.0",
"bluebird": "^3.5.0",
"body-parser": "^1.17.2",
"classnames": "^2.2.5",
"cookie-parser": "^1.4.3",
"core-js": "^2.4.1",
"express": "^4.15.3",
"express-graphql": "^0.6.6",
"express-jwt": "^5.3.0",
"graphql": "^0.10.3",
"history": "^4.6.3",
"isomorphic-style-loader": "^2.0.0",
"jsonwebtoken": "^7.4.1",
"material-ui": "^0.18.6",
"node-fetch": "^1.7.1",
"normalize.css": "^7.0.0",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"pretty-error": "^2.1.1",
"prop-types": "^15.5.10",
"query-string": "^4.3.4",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-tap-event-plugin": "^2.0.1",
"sequelize": "^4.2.1",
"serialize-javascript": "^1.3.0",
"source-map-support": "^0.4.15",
"sqlite3": "^3.1.8",
"universal-router": "^3.2.0",
"whatwg-fetch": "^2.0.3"
},

You are most probably missing the react-tap-event-plugin.
Add it with npm install -save react-tap-event-plugin

I strugged with this problem for couple of days and found a solution. See if it works for you
Why was it not working?
If you look closely at the backend code of RadioButton you'll realize that it is actually similar to the Checkbox. I realized the problem was not only with RadioButtons but the checkbox was also not working (while the toggles were working fine).
I took my source code and ran it using CRA (Create React App) and it the RadioButtons were working perfectly. For RSK (React Starter Kit) the first suspect which was different was BrowserSync. I dug a little deeper and found that there is a config in BrowserSync for Ghost clicks which was to be turned off. You can read more about it here
https://github.com/callemall/material-ui/issues/2983
To turn off Ghost mode in your start script, goto /tools/start.js in your RSK Project folder and change config to
browserSync.create().init(
{
// https://www.browsersync.io/docs/options
server: 'src/server.js',
ghostMode: false,
middleware: [server],
open: !process.argv.includes('--silent'),
...(isDebug ? {} : { notify: false, ui: false }),
},
(error, bs) => (error ? reject(error) : resolve(bs)),
),

Related

Can't resolve '#material-ui/core/TableContainer

I want to import table container for my react application. but I can't use it because of my material ui version error.
How i update my version to latest version. I suppose that it's the solution for that error.
I have already tried npm uninstall and npm uninstall, but didn't solve yet. Help me.
{
"name": "material-dashboard-react",
"version": "1.6.0",
"description": "Material Dashboard React. Coded by Creative Tim",
"private": false,
"main": "dist/index.js",
"dependencies": {
"#khanacademy/react-multi-select": "^0.3.3",
"#lls/react-light-calendar": "^2.0.7",
"#material-ui/core": "^3.9.4",
"#material-ui/icons": "3.0.2",
"#progress/kendo-react-dropdowns": "^3.4.1",
"#progress/kendo-react-intl": "^3.4.1",
"animate.css": "^3.7.2",
"axios": "^0.19.1",
"bootstrap": "^4.3.1",
"chartist": "0.10.1",
"classnames": "2.2.6",
"firebase": "^7.0.0",
"history": "4.7.2",
"jquery": "^1.9.1",
"material-ui-next-responsive-table": "^0.5.1",
"multi-select-react": "^0.1.8",
"multiselect-dropdown-react": "^1.0.5",
"multiselect-react-dropdown": "^1.2.4",
"perfect-scrollbar": "1.4.0",
"prettier": "1.16.4",
"prop-types": "15.7.1",
"react": "^16.8.1",
"react-bootstrap": "^1.0.0-beta.12",
"react-bootstrap-dialog": "^0.13.0",
"react-bootstrap-modal": "^4.2.0",
"react-chartist": "0.13.3",
"react-confirm-alert": "^2.4.1",
"react-datepicker": "^2.9.6",
"react-devtools": "^4.4.0",
"react-dialog": "^1.0.2",
"react-dom": "16.8.1",
"react-dropdown": "^1.6.4",
"react-dropdown-multiselect": "^1.0.0",
"react-dropdown-tree-select": "^2.1.1",
"react-google-maps": "9.4.5",
"react-light-calendar": "^1.0.3",
"react-multiple-select-dropdown": "^2.0.0",
"react-multiselect-checkboxes": "^0.1.1",
"react-notification-alert": "0.0.12",
"react-notifications": "^1.4.3",
"react-notifications-component": "^2.1.0",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.5",
"react-select": "^3.0.8",
"react-swipeable-views": "0.13.1",
"react-table-container": "^2.0.3",
"react-toastify": "^5.4.0",
#material-ui/core version ^3.9.4 doesn't have <TableContainer>
so you need to update #materia-ui/core version
latest version v4.9.2, so please update version and try
1) Go to package.json file in your project root.
2) Locate #material-ui/core in dependencies. Currently, you will see it as "#material-ui/core": "^3.9.4".
3) Now edit the version number. For example, "#material-ui/core": "^4.9.2".
4) Run npm install.
That's it!
You can follow this procedure for any dependency when you want to change the version. But make sure that those versions are compatible with each other dependencies (if any).
Good luck!

Create React App not injecting CSS (SCSS) anymore

since a couple of days I have a problem, where CRA does not inject SCSS changes anymore.
If I refresh the page manually, the SCSS code change is there and applied to my page.
If I change my JavaScript, the change is detected and the app hot reloads.
I was on the 3.0 version of react-scripts, and now I upgraded to the latest, 3.2.0.
Still, SCSS is not injected.
In case it's useful, here are the packages in my package.json file:
"dependencies": {
"#aspnet/signalr": "^1.1.4",
"#reach/router": "^1.2.1",
"axios": "^0.18.0",
"bcryptjs": "^2.4.3",
"css-vars-ponyfill": "^2.1.1",
"dayjs": "^1.8.14",
"dompurify": "^1.0.10",
"draft-js": "^0.10.5",
"draftjs-to-html": "^0.8.4",
"google-maps-react": "^2.0.2",
"html-to-draftjs": "^1.4.0",
"i18next": "^15.1.0",
"i18next-browser-languagedetector": "^3.0.1",
"i18next-xhr-backend": "^2.0.1",
"interweave": "^11.1.0",
"node-sass": "^4.13.0",
"prop-types": "^15.7.2",
"pubnub": "^4.25.2",
"react": "^16.8.6",
"react-anchor-link-smooth-scroll": "^1.0.12",
"react-app-polyfill": "^1.0.1",
"react-dom": "^16.8.6",
"react-draft-wysiwyg": "^1.13.2",
"react-dropzone": "^10.1.5",
"react-ga": "^2.5.7",
"react-google-maps": "^9.4.5",
"react-i18next": "^10.9.0",
"react-image-crop": "^8.2.0",
"react-modal": "^3.8.1",
"react-redux": "^7.0.3",
"react-scripts": "3.2.0",
"react-scroll-up": "^1.3.3",
"react-tooltip": "^3.10.0",
"react-twitter-embed": "^2.0.8",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"uniqid": "^5.0.3"
},
}
Does anybody have any idea what might have caused it, or what I might try in order to troubleshoot the issue?
edit: I have noticed that when I save a scss file, a hot-update.js file is added to the DOM. this file contains my css changes, but they do not take effect.
so the issue seemed to be related to the fact that i was injecting some code in the head of the document (for the favicons) just before the app was loaded, following a fetch on a server containing the favicon urls.
Removing this fixed the HMR. Thanks for your help

Heroku package.json issue

Package.json :
{
"private": true,
"scripts": {
...
},
"devDependencies": {
"axios": "^0.18",
"babel-preset-react": "^6.23.0",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.4",
"popper.js": "^1.12",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"gh-pages": "^2.0.1",
"react-icons": "^3.2.2",
"react-redux": "^5.0.7",
"react-scripts": "1.1.5",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"styled-components": "^4.0.2"
},
"dependencies": {
"react-router-dom": "^4.3.1"
}
}
After deploying laravel app (with react) im having error:
Uncaught Error: Cannot find module "react-redux"
Im having blank site with above error in console.
Heroku installs only production dependencies on deployment by default, so the ones that are listed under dependencies key of you package.json by running npm install --production.
Move dependencies that are crucial to your app running from devDependencies to dependencies and that should solve your problem.
devDependencies are meant for things that support you in development, but are not required for the production copy of your app to run, like testing modules, for example.

How to serve static assets like json file in webpack dev server?

I am building a react app. I have used yeoman to generate the react app structure. I am using webpack to bundle all js files. My package.json is -
{
"dependencies": {
"axios": "^0.15.0",
"classnames": "^2.2.5",
"es6-shim": "^0.35.0",
"react": "^15.0.1",
"react-dom": "^15.0.1",
"react-mdl": "^1.7.2",
"react-redux": "^4.4.5",
"react-router": "^2.4.0",
"redux": "^3.5.1",
"todomvc-app-css": "^2.0.4"
},
"devDependencies": {
"autoprefixer": "^6.2.2",
"babel-core": "^6.13.0",
"babel-eslint": "^6.0.2",
"babel-loader": "^6.2.0",
"babel-plugin-istanbul": "^2.0.1",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.2.0",
"babel-preset-react": "^6.1.18",
"browser-sync": "^2.9.11",
"browser-sync-spa": "^1.0.3",
"css-loader": "^0.23.1",
"del": "^2.0.2",
"es6-shim": "^0.35.0",
"eslint": "^3.2.2",
"eslint-config-xo-react": "^0.7.0",
"eslint-config-xo-space": "^0.12.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-babel": "^3.1.0",
"eslint-plugin-react": "^5.0.1",
"extract-text-webpack-plugin": "^2.0.0-beta.3",
"file-loader": "^0.9.0",
"gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb",
"gulp-filter": "^4.0.0",
"gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4",
"gulp-sass": "^2.1.1",
"gulp-util": "^3.0.7",
"html-webpack-plugin": "^2.9.0",
"jasmine": "^2.4.1",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-junit-reporter": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.0",
"karma-phantomjs-shim": "^1.1.2",
"karma-webpack": "^1.7.0",
"node-sass": "^3.4.2",
"phantomjs-prebuilt": "^2.1.6",
"postcss-loader": "^0.8.0",
"react-addons-test-utils": "^15.0.1",
"react-hot-loader": "^1.3.0",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"webpack": "2.1.0-beta.20",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0"
},
"scripts": {
"build": "gulp",
"serve": "gulp serve",
"serve:dist": "gulp serve:dist",
"test": "gulp test",
"test:auto": "gulp test:auto"
},
"eslintConfig": {
"root": true,
"env": {
"browser": true,
"jasmine": true
},
"extends": [
"xo-react/space",
"xo-space/esnext"
]
}
}
I am using axios to make http requests. Presently, I have not coded a server to return a json data. Hence, to test the app's functionality, I want to serve static json data from a json file.
How can I achieve this ?
Since this setup is running a web-server, I hope a json file can be served using something like - axios.get('http://localhost:3000/user.json').
If you're starting your app from the Facebook's 'create-react-app' instructions found here: https://facebook.github.io/react/docs/installation.html
Then I found an easy way to be able to access JSON files from the URL without having the React Router get in the way and intercept the request.
All you have to do is in your index.js of that 'create-react-app' scaffolding, add something like this as the very first line:
import './myJsonFile.json';
And that's it, as afterwards going to:
http://localhost:3000/myJsonFile.json
would correctly fetch the file without React router interfering in the lookup.
(maybe it wasn't exactly your question as you've used a different way to generate the app, but this would be an answer for those who use the 'create-react-app' as a base).
You can use the webpack file-loader to have webpack serving that file as if it was any other static files, e.g. an image.
You can try with this in your "main" (entrypoint) file:
require("file-loader?name=api/[name].[ext]!./user.json");
This require is just needed to tell webpack to "emit" that file in the output destination, otherwise it doesn't know anything about it.
You also need to install the file-loader:
npm install --save-dev file-loader
Then with webpack-dev-server you should be able to access that file from http://localhost:8080/api/user.json (replace localhost:8080 according to your webpack dev server config).
However, if you need to stub a json api, I'd rather use something like these:
https://www.npmjs.com/package/json-server
https://www.npmjs.com/package/dyson
that are more flexible and can handle more advanced thing like serving the response with the right content type, testing cross domain issues, JSONP, etc.
If you want something simpler, you can use this: https://www.npmjs.com/package/superstatic to simply serve static files,
or even simpler, check out how these one-liners to start a simple http server to serve your static json files:
https://gist.github.com/willurd/5720255

Convert Application from React 0.13.3 to React 0.14

I have developed a React Application in which below mentioned modules I have used.
"babel-runtime": "^5.1.10",
"core-js": "^0.9.6",
"flux": "^2.0.1",
"fs": "0.0.2",
"griddle-react": "^0.2.13",
"humps": "0.0.1",
"invariant": "^2.0.0",
"joi": "^6.5.0",
"keymirror": "^0.1.1",
"material-ui": "^0.9.0",
"moment": "^2.10.6",
"normalizr": "^0.1.2",
"react": "^0.13.3",
"react-bootstrap": "^0.23.1",
"react-bootstrap-datetimepicker": "0.0.18",
"react-bootstrap-table": "^0.9.7",
"react-color-picker": "^2.1.6",
"react-data-components": "^0.4.0",
"react-datepicker": "^0.11.4",
"react-day-picker": "^1.0.1",
"react-dnd": "^1.1.1",
"react-document-title": "^1.0.0",
"react-flex-layout": "^0.9.2",
"react-intl": "^1.2.0",
"react-pure-render": "^1.0.1",
"react-router": "^0.13.3",
"react-select": "^0.6.3",
"react-spinner": "^0.2.1",
"react-validation-mixin": "^4.1.0",
"selectn": "^0.9.6",
"underscore": "^1.8.2",
"validator": "^3.40.1",
"webpack": "^1.11.0",
"whatwg-fetch": "^0.7.0",
"xml2js": "^0.4.12"
Now I want to upgrade React 0.13.3 to 0.14 I know facebook has already released the document but I am not clear about it if I will update the react with 0.14 then what about dependencies how new react version is applicable to dependencies modules how I can upgrade dependencies as well.please guide me.
You could run a regex over your node_modules folder package.json files after running npm update.
Since we know that ^version means "Compatible with version" the regex would be "react": "^0.14.0" to check what packages are compatible with React 0.14.0.
If you're on an Unix based OS, one (untested) way would be:
grep -ER --include="**/package.json" "\"react\": \"\^0\.14\.0\"" project_root_path/node_modules

Resources