How do you programmatically update query params in react-router?

I can’t seem to find how to update query params with react-router without using <Link/>. hashHistory.push(url) doesn’t seem to register query params, and it doesn’t seem like you can pass a query object or anything as a second argument. How do you change the url from /shop/Clothes/dresses to /shop/Clothes/dresses?color=blue in react-router without using <Link>? And … Read more

Typescript react – Could not find a declaration file for module ”react-materialize’. ‘path/to/module-name.js’ implicitly has an any type

I am trying to import components from react-materialize as – import {Navbar, NavItem} from ‘react-materialize’; But when the webpack is compiling my .tsx it throws an error for the above as – ERROR in ./src/common/navbar.tsx (3,31): error TS7016: Could not find a declaration file for module ‘react-materi alize’. ‘D:\Private\Works\Typescript\QuickReact\node_modules\react-materialize\l ib\index.js’ implicitly has an ‘any’ type. … Read more

Axios get in url works but with second parameter as object it doesn’t

I’m trying to send GET request as second parameter but it doesn’t work while it does as url. This works, $_GET[‘naam’] returns test: export function saveScore(naam, score) { return function (dispatch) { axios.get(‘http://****.nl/****/gebruikerOpslaan.php?naam=test’) .then((response) => { dispatch({type: “SAVE_SCORE_SUCCESS”, payload: response.data}) }) .catch((err) => { dispatch({type: “SAVE_SCORE_FAILURE”, payload: err}) }) } }; But when I try … Read more

create react app not picking up .env files?

I am using create react app to bootstrap my app. I have added two .env files .env.development and .env.production in the root. My .env.development includes: API_URL=http://localhost:3000/api CALLBACK_URL=http://localhost:3005/callback When I run my app using react-scripts start and console out process.env it spits out { NODE_ENV: “development”, PUBLIC_URL: “” } I’ve tried different things, but its just … Read more

Is it possible to return empty in react render function?

I have a notification component, and I have a timeout setting for it. After timeout I call this.setState({isTimeout:true}). What I want to do is if already timeout, I want just render nothing: render() { let finalClasses = “” + (this.state.classes || “”); if (isTimeout){ return (); // here has some syntax error } return (<div>{this.props.children}</div>); … Read more

React.createElement: type is invalid — expected a string

Trying to get react-router (v4.0.0) and react-hot-loader (3.0.0-beta.6) to play nicely, but getting the following error in the browser console: Warning: React.createElement: 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. index.js: … Read more