Updates to props values are not being reflected in the React js application running on the webpack

I keep facing an issue where I have to restart the webpack server every time I try to pass or update props values from parent to child components. It's frustrating that the props values are not updating even after saving the file.

Take a look at my package.json file

{
  "name": "react-hooks",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server .",
    "build": "Webpack .",
    "test": "test"
  },
  "author": "Rasith",
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.17.10",
    "@babel/core": "^7.17.10",
    "@babel/plugin-transform-runtime": "^7.17.10",
    "@babel/preset-env": "^7.17.10",
    "@babel/preset-react": "^7.16.7",
    "@babel/runtime": "^7.17.9",
    "babel-eslint": "^10.1.0",
    "babel-loader": "^8.2.5",
    "webpack": "^5.72.1",
    "webpack-cli": "^4.9.2",
    "webpack-dev-server": "^4.9.0"
  },
  "dependencies": {
    "axios": "^0.27.2",
    "react": "^18.1.0",
    "react-dom": "^18.1.0"
  }
}

This is the content of my webpack.config.js file

const path = require("path");

module.exports={

    mode: "development", 
    entry: "./index.js", 
    output: {

        path: path.resolve(__dirname, "public"),
        filename: "main.js"
    },

    target: "web",
    devServer: {
        port: "9500",
        static: ["./public"],
        open: true,
        hot: true ,
        liveReload: true
    },
    resolve: {

        extensions: ['.js','.jsx','.json'] 
    },
    module:{

        rules: [
            {
                test: /\.(js|jsx)$/,   
                exclude: /node_modules/, 
                use:  'babel-loader'
            }
        ]
    }
}

Next, let's check the babel.rc file

{

    "presets": [
        "@babel/preset-env", //compiling ES2015+ syntax
        "@babel/preset-react" //for react
    ],
    "plugins": [
        "@babel/plugin-transform-runtime"
    ]
}

I seem to be missing some dependencies or modules in these files. Any suggestions on what might be causing this issue? Appreciate any help from fellow developers. Thank you!

Answer №1

If you're looking to enable hot module replacement (HMR), consider using the HMR plugin.

To implement this, add the following code snippet to your webpack configuration file:

plugins: [
  new webpack.HotModuleReplacementPlugin({
   multiStep: true
  })
]

Learn more about the HMR plugin at https://webpack.js.org/plugins/hot-module-replacement-plugin/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"I am encountering an issue where I am using React and Express to retrieve data from a database, and although I am able to return an array of

I am working on a React app that communicates with an API using Express. Currently, I am using the GET method to fetch data from a database, and my fetching code looks like this: const posts = []; fetch(URL) .then(response => response.json()) .then(jso ...

The Algolia Hit Component is having difficulty functioning properly within a grid layout

I am in the process of converting my next API to an Algolia search. The Hit component is a single component that renders for each record. However, I am facing an issue with implementing a grid layout. Below is the code snippet from before (which was workin ...

Ways to retrieve information from a POST request

I am looking for assistance on extracting data from a post request and transferring it to Google Sheets while also confirming with the client. Any guidance or support would be highly appreciated. Thank you. My project involves creating a web application f ...

Calling Ajax in JavaScript

Trying to fetch a value in JavaScript using an Ajax Call, The code being used is as follows: <script> var value = $.ajax({ type:"GET", url:"get_result.php", data:"{'abc':" + $abc + "}", }); alert(val ...

An error was encountered when trying to read property '0' of an undefined object in a for loop

Currently, I am working on a project to create a mastermind game. Everything is progressing smoothly, except for one issue that keeps popping up - I keep encountering the error: "uncaught typeerror cannot read property '0' of undefined." fun ...

Exploring creative solutions for generating PDFs with Node JS

Looking for a way to generate PDF Documents in Node.JS? Is there an alternative solution for organizing templates for various types of PDF creation? I've been utilizing PDFKit for creating PDF Documents on the server side with Javascript. Unfortunate ...

Guide to smoothly scroll to a specific Label using GSAP's scrollTrigger and scrubbing within a Timeline

Currently facing an issue with a scrollTrigger Timeline where I need a button to scroll to a specific position. I attempted using seek but it did not work, and even the ScrollTo plugin lacks support for this functionality. The Timeline created using gsap ...

Which specific html container or element can be found on the mymsn pages?

When accessing mymsn, users have the ability to personalize the content and layout of their webpage. I am curious about what type of container is being utilized for this customization - does it involve an html element, or perhaps javascript, or something e ...

How can you customize the 'clear' icon in Material UI TextField with type='search'?

For this scenario, I have implemented a text field with the attribute type='search'. https://i.stack.imgur.com/aQguP.png The default 'clear' icon is displayed. Is there a way for me to customize the appearance of this icon or substitut ...

Linking an external URL with a button using Material UI - A simple guide

I'm currently exploring Material-UI and testing my web application on localhost. I've added a button that should redirect users to an external URL (currently set as www.google.ca) when clicked. However, instead of redirecting to the correct URL ( ...

Creating an HTTPS server that can be accessed via my specific IP address

My attempt to create ad hoc and OpenSSL based certificates in Python Flask was inspired by a tutorial I found on this website. I also explored the method of creating root CA, trusting it, and generating certificates as outlined on this GitHub thread using ...

What is the method to adjust the anchor point for a MUI popover?

I currently have the following code for handling a popover: const [open, setOpen] = useState(false); const anchorRef = createRef() const handleClose = () => { setOpen(false); }; const handleClick = useCallback( (event: MouseEvent<H ...

Having trouble with the Ajax load function not functioning in your HTML code?

The issue has been resolved. Thank you to everyone who helped! Initially, I was attempting to run a file offline instead of on a web server (XAMPP server). Once I uploaded the file to the web server, it started working properly. I had been trying to load ...

What is the best way to conceal all input elements in a form?

I have been attempting to conceal input elements within my form by using the code snippet below. Unfortunately, it doesn't seem to be functioning as expected... <html lang="en"> <head> <title>example</title> < ...

Rebounding Movement on iPad (React)

I've tried numerous solutions, but none seem to work. I have a page with scrollable content if necessary. While it functions properly in Windows Chrome and Firefox, iOS and Safari introduce an undesired vertical bouncing scroll. Some users have recom ...

Upon transitioning from typescript to javascript

I attempted to clarify my confusion about TypeScript, but I'm still struggling to explain it well. From my understanding, TypeScript is a strict syntactical superset of JavaScript that enhances our code by allowing us to use different types to define ...

Error: Unable to access attributes of null object (specifically 'disable click')

Currently, I am integrating react-leaflet with nextjs. Within the markers, there are popups containing buttons that open another page upon click. However, I have encountered an error when navigating to the new page: Unhandled Runtime Error TypeError: Canno ...

Getting the user's name and country using `auth().createUserWithEmailAndPassword` is a simple process

Hey there fellow developers. I'm fairly new to react native and I'm trying to implement firebase authentication for a project. However, I'm stuck on how to include user name and country when using the standard auth().createUserWithEmailAndPa ...

Error: The session ID is not currently active

I encountered a problem with my tests failing when running them on TFS, showing the following error: WebDriverError: No active session with ID Failed: No active session with ID Interestingly, these same tests are passing locally. Everything was working ...

Error encountered during npm run build: Attempting to convert an undefined property to lowercase

Every time I attempt to compile my react application, an error keeps popping up: Cannot read property 'toLowerCase' of undefined CompileError: Begins at CSS selector .btn-white I have gone through various forum responses and attempted to remove ...