React Router: Cannot read property ‘pathname’ of undefined

I got the above error message and it was extremely cryptic. I tried the other solutions mentioned and it didn’t work. Turns out I accidentally forgot to include the to prop in one of the <Link /> components. Wish the error message was better. A simple required prop “to” not found or something like that … Read more

Create-React-App build – “Uncaught SyntaxError: Unexpected token

Thanks this helped me a lot. Just wanting to add to this with an example from a Create-React-App project that had the same solution: I received the same error after deploying to heroku. Uncaught SyntaxError: Unexpected token < after serve -s build For me the problem was in the packages.json file. The “homepage” parameter i … Read more

Warning: Prop `className` did not match. when using styled components with semantic-ui-react

This warning was fixed for me by adding an .babelrc file in the project main folder, with the following content: { “presets”: [“next/babel”], “plugins”: [[“styled-components”, { “ssr”: true }]] } See following link for an example: https://github.com/nblthree/nextjs-with-material-ui-and-styled-components/blob/master/.babelrc

How to concatenate two JSX fragment or variables or string and component (in Reactjs)?

Use arrays: let lineComponent = <Line key={line.client_id} line={line}/>; if (line.created_at) { return [ <div key=”date” className=”date-line”><strong>{line.created_at}</strong></div>, lineComponent, ]; } else { return chat_line; } Or use fragments: import createFragment from “react-addons-create-fragment”; let lineComponent = <Line key={line.client_id} line={line}/>; if (line.created_at) { return createFragment({ date: <div className=”date-line”><strong>{line.created_at}</strong></div>, lineComponent: lineComponent, }); } else { return chat_line; } In … Read more

Problem with Visual Studio Code using “react-jsx” as jsx value with create-react-app

This is because VSCode’s Typescript version is not using the newest babel features that create-react-app uses by default. You can change VS Code to use the workspace’s version of Typescript instead, which will fix this issue. Open a TypeScript or JavaScript file and click on the TypeScript version number in the Status Bar. A message … Read more