Ramya Velivala
Ramya Velivala

Reputation: 567

Minified React error #152 - how to resolve this?

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?

Upvotes: 29

Views: 84366

Answers (8)

Henry M
Henry M

Reputation: 105

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; // No longer a boolean
    }

Upvotes: 6

Rahul Kumar RJ
Rahul Kumar RJ

Reputation: 1

I had the same issue. // Remove All Comments in This Component

otherwise

apply condition && don't do like this:

{condition && (<Permission allowed={[]} />)}

Do like this:

{condition ? (<Permission allowed={[]} />) : null}

Upvotes: 0

Zachary Johnson
Zachary Johnson

Reputation: 67

In our instance, this was not related to comments inside the react HTML at all, it had to do with CMS changes. If you go through your react HTML and find no comments, try taking a look at other tools you are using that may be having an effect on your site.

Upvotes: 0

Mohammed Hisham mp
Mohammed Hisham mp

Reputation: 21

I have the same issue check your useState import

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

Upvotes: 2

user3467734
user3467734

Reputation:

I accidentally imported it from here:

import {useState} from "react/cjs/react.production.min";

use import from import React, {useState} from 'react'; instead

That fixed the issue

Upvotes: 0

WEBKIRA
WEBKIRA

Reputation: 37

I had same issue. So i removed comments inside my render function and it worked!

Upvotes: 1

Moumit
Moumit

Reputation: 9630

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

Upvotes: 35

Lunigorn
Lunigorn

Reputation: 1422

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

Upvotes: 31

Related Questions