Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minified React error #152 - how to resolve this?

Tags:

reactjs

I am getting below error even though I am building using dev environment. Below is my package.json file.

Error: "for the full message or use the non-minified dev environment for full errors and additional helpful warnings."

Package.json file:

 "scripts": {
    "compile": "webpack",
    "start": "node server.js",
    "dev": "webpack --mode development",
    "build": "webpack --mode production",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

I do npm run build and then npm run start. Still I am getting the same minified error, I tried to delete bundle.js or ./dist folder and done building in dev environment, still I face the same issue.

Could anyone help me, how can I avoid this minified version and debug the files easily in local?

like image 398
Ramya Velivala Avatar asked May 23 '18 20:05

Ramya Velivala


People also ask

What is React Minified error?

In the minified production build of React, they avoid sending down full error messages. Instead, we can use the error code to view the full message for full errors and additional helpful warnings. This small tool is meant to mitigate this gap.

What is Minified React error #185?

#185 text: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

How do you solve a Minified React error #130?

You need to import without curly brackets in the case of export default: export default class MyInput extends React. Component { ... } import MyInput from './MyInput.


4 Answers

Remove any comment inside render/ return method

I used this regex in VSCode to find the troublesome comments: (\s*\n?\s*//

enter image description here

More help here

like image 187
Moumit Avatar answered Oct 23 '22 21:10

Moumit


The error description is here, you return nothing as result of rendermethod of you react component. Return something else instead of it.

like image 20
Lunigorn Avatar answered Oct 23 '22 19:10

Lunigorn


In case it helps someone, I resolved this problem by returning null instead of false (my function is wrapped inside an HOC)

Edit: sometimes I did not want to render anything. In such case, I returned false in the render method as something like this:

    render(){
        return condition && <ThingsIWantToDisplay/>; //condition is a boolean
    }

The component class is then wrapped within an HOC (to provide React Context) like this:

export default HOC(Component);

 

When condition is false, an error occurs in the production build.

Changing the render function as shown below alleviated the problem:

    render(){
        return condition?<ThingsIWantToDisplay/>:null; //condition is a boolean
    }
like image 6
Henry M Avatar answered Oct 23 '22 21:10

Henry M


I have the same issue check your useState import

import { useState } from 'react/cjs/react.production.min'; change into import react,{usestate} from 'react'

like image 2
Mohammed Hisham mp Avatar answered Oct 23 '22 20:10

Mohammed Hisham mp