NPM Start not starting local server

I am trying to make an react app using webpack and when I try to run npm start it should load http://localhost:3333 but it says site cannot be reached, here is my webpack config: And here is my script object from package.json: “start”: “webpack-dev-server”. I have already installed webpack & webpack-dev-server globally. Check below image which I am getting:  … Read more

Can’t resolve module (not found) in React.js

The way we usually use import is based on relative path. . and .. are similar to how we use to navigate in terminal like cd .. to go out of directory and mv ~/file . to move a file to current directory. In your case, App.js is in src/ directory while header.js is in src/components. To import you would do import Header from ‘./components/header’. This roughly translate to in my current directory, find the components folder that … Read more

Loop inside React JSX

Think of it like you’re just calling JavaScript functions. You can’t use a for loop where the arguments to a function call would go: See how the function tbody is being passed a for loop as an argument – leading to a syntax error. But you can make an array, and then pass that in as an argument: You can basically … Read more

How to use clsx in React

clsx is generally used to conditionally apply a given className This syntax means that some class will only be applied if a given condition evaluates to true In this example [classes.menuOpen] (which will evaluate to something like randomclassName123) will only be applied if open === true clsx basically outputs a string interpolation. So you don’t have to necessarily use it, although is a common practice. … Read more

How to use clsx in React

clsx is generally used to conditionally apply a given className This syntax means that some class will only be applied if a given condition evaluates to true In this example [classes.menuOpen] (which will evaluate to something like randomclassName123) will only be applied if open === true clsx basically outputs a string interpolation. So you don’t have to necessarily use it, although is a common practice. … Read more

TypeScript React.FC confusion

Function ComponentsThese can be written as normal functions that take a props argument and return a JSX element. What about React.FC/React.FunctionComponent? You can also write components with React.FunctionComponent (or the shorthand React.FC): Some differences from the “normal function” version: It provides typechecking and autocomplete for static properties like displayName, propTypes, and defaultProps – However, there are currently known issues using defaultProps with React.FunctionComponent. See this issue for details … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)