Error – Expected an assignment or function call and instead saw an expression

Expected an assignment or function call and instead saw an expression is a common error whenever I forget adding return keyword to a function.

if(!loading) {
        return <p>Loading...</p>
    }
    else if (error) {
        <p>Some error occurred</p>
 //Error
    }

In the else if return statement, I missed the return keyword, causing this error.

if(!loading) {
        return <p>Loading...</p>
    }
    else if (error) {
        return <p>Some error occurred</p>
    }

Problem solved.

Published by Jayesh

I code and energize, loves sharing my journey.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s