RangeError: Maximum call stack size exceeded (React) - reactjs

This is my first app in React. In localhost everything works fine, and when I deploy with Github Pages, some pages from my app (Info / Images / Évenements) doesn't render. Every time when I click in their link to access them, I get a white page and this error on my console:
RangeError: Maximum call stack size exceeded at Object.toString.
Also When I refresh the page, github pages returns a 404 page.
There's my package:
{
"name": "gyuto-web",
"version": "0.1.0",
"private": true,
"dependencies": {
"#u-wave/react-vimeo": "^0.5.0",
"auditjs": "^3.0.10",
"bulma": "^0.7.2",
"gh-pages": "^2.0.1",
"gsap": "^2.0.2",
"i18next": "^13.0.0",
"i18next-browser-languagedetector": "^2.2.4",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-flexbox-grid": "^2.1.2",
"react-helmet": "^5.2.0",
"react-i18next": "^8.4.0",
"react-media": "^1.8.0",
"react-router-dom": "^4.3.1",
"react-router-page-transition": "^3.1.0",
"react-scripts": "2.0.5",
"react-transition-group": "^2.5.0",
"rodal": "^1.6.3"
},
"scripts": {
"start": "react-scripts start",
"predeploy": "yarn run build",
"deploy": "gh-pages -b master -d build",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"node-sass": "^4.9.4",
"sass-loader": "^7.1.0"
}
}
The error is reported on react-dom.production.min.js line 3869 & 5081:
function supported(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
Here's an exemple of a component not rendering in production:
PageImages.jsx
import React, { Component, Fragment } from "react";
import { Helmet } from 'react-helmet';
import { images } from "../data";
import { Row, Col } from "react-flexbox-grid";
import { Link, NavLink } from "react-router-dom";
import Image from "./assets/Image";
import { withNamespaces } from 'react-i18next';
class PageImages extends Component {
render() {
const listGaleries = images.map(i => {
if (i.id) {
return (
<Col key={i.id} xs={12} sm={6} md={6} lg={4}>
<Link to={`/images/${i.id}`}>
<Image imagesObject={i} />
</Link>
</Col>
);
} else {
return (
<Fragment>
<Helmet>
<style>{'body { background-color: #f5f5f5 !important; } a.itemsColor{color: black} .cursor{display:none}'}</style>
<title>{this.props.t('nav.images')}</title>
</Helmet>
<div className="pageNotFoundCtr">
<p>
{this.props.t('nav.soon')}
</p>
<p>
<NavLink to={"/doclist"} className="snapCursor js-click" data-snap-scale="3.5">
{this.props.t('nav.doclistPage')}
</NavLink>
</p>
</div>
</Fragment>
)
}
})
return (
<Fragment>
<Helmet>
<title>{this.props.t('nav.images')}</title>
<style>{'body { background-color: #f5f5f5 !important; } a.itemsColor{color: black} .cursor{display:none}'}</style>
</Helmet>
<Row className="imagesRow">{listGaleries}</Row>
</Fragment>
);
}
}
export default withNamespaces('common')(PageImages);
Image.jsx
import React, { Component } from "react";
class Image extends Component {
render() {
return (
<div className="galeries container">
<div className="parentZoomIn">
<div
className="childZoomIn"
style={{
backgroundImage: `linear-gradient(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url("${
this.props.imagesObject.cover
}")`
}}
>
<div className="text">
<p>{this.props.imagesObject.title.fr}</p>
</div>
</div>
</div>
</div>
);
}
}
export default Image;
Does someone knows why it's happening on production, and not on development, and a way to fix it?
Thanks

Upgrade to v5.2.1 or higher and this open issue should be fixed
yarn upgrade -L react-helmet

Related

Algolia's searchBox is stuck and is not accepting new values

I'm trying to type new values ​​after instantiating Algolia's SearchBox, but it doesn't change the input value at all. I've recreated the NextJs boilerplate and implemented it 5 times, but the value never changes. What could it be?
In short: when I type something in the input, the value just doesn't update
Github:
https://github.com/Arthur-Maskalenkas/bug-report
sandbox:
https://codesandbox.io/p/github/Arthur-Maskalenkas/bug-report/csb-zf1foq/draft/happy-smoke?file=%2FREADME.md
my currently index.tsx is
import type { NextPage } from 'next'
import algoliasearch from 'algoliasearch/lite';
import {
InstantSearch,
SearchBox,
Pagination,
Configure,
} from 'react-instantsearch-dom';
const Home: NextPage = () => {
const searchClient = algoliasearch(
'B1G2GM9NG0',
'aadef574be1f9252bb48d4ea09b5cfe5'
);
return (
<div className="ais-InstantSearch">
<h1>React InstantSearch e-commerce demos</h1>
<InstantSearch searchClient={searchClient} indexName="demo_ecommerce">
<Configure hitsPerPage={8}/>
<div className="search-panel">
<div className="search-panel__filters">
</div>
<div className="search-panel__results">
<SearchBox
className="searchbox"
translations={{
placeholder: ''
}}
/>
<div className="pagination">
<Pagination/>
</div>
</div>
</div>
</InstantSearch>
</div>
)
}
export default Home
my package
{
"name": "teste2",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"algoliasearch": "^4.14.2",
"next": "12.3.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-instantsearch-dom": "^6.33.0"
},
"devDependencies": {
"#types/node": "18.7.20",
"#types/react": "18.0.21",
"#types/react-dom": "18.0.6",
"#types/react-instantsearch-dom": "^6.12.3",
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"typescript": "4.8.3"
}
}
There is a known issue with React 18.x strict mode and older InstantSearch libraries. The resolution is to set reactStrictMode: false in next.config.js (not recommended), downgrade to React 17, or move to the newer react-instantsearch-hooks library as documented here: https://github.com/algolia/react-instantsearch/issues/3634

ReactJS - Uncaught TypeError: Cannot set property default of #<Object> which has only a getter

Image of Error
Facing an error while coding using React.js. I have know idea about it. Hence i don't know how to ask this question. Besides, I have attached an image of an error file. Putting the App.js, Header.js and package.json files. I have been trying to resolve the issue for an hour but couldn't get the success. Please help.
App.js
import { Fragment } from "react";
import Header from "./components/Layout/Header";
function App() {
return (
<Fragment>
<Header/>
</Fragment>
);
}
export default App;
Header.js
import React, {Fragment} from 'react'
import mealsImage from '../../assets/meals.jpg'
import classes from './Header.module.css'
const Header = (props) => {
return (
<Fragment>
<header className={classes.header}>
<h1>ReactMeals</h1>
<button>Cart</button>
</header>
<div className={classes=['main-image']}>
<img src={mealsImage} alt='A Table full of delicious meals' />
</div>
</Fragment>
)
}
export default Header
Package.json
{
"name": "react-complete-guide",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.3.0",
"#testing-library/user-event": "^13.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Try to change the className of the img container to:
<div className={classes['main-image']}>
You have issue in Header.js file, let me provide you fix code
import React, {Fragment} from 'react'
import mealsImage from '../../assets/meals.jpg'
import classes from './Header.module.css'
const Header = (props) => {
return (
<Fragment>
<header className={classes.header}>
<h1>ReactMeals</h1>
<button>Cart</button>
</header>
<div className={classes['main-image']}> {/* issue was here you were using classes=['main-image'], you do not need = here */}
<img src={mealsImage} alt='A Table full of delicious meals' />
</div>
</Fragment>
)
}
export default Header

Module not found: Error: Package path . is not exported from package react

I am getting following error in my react application. This issue started when I renamed some components and deleted some. However I look closely and imports and component names are correct. I did a fresh checkout, renamed one component and got the same issue.
ERROR in ./src/components/courses/CourseList.js 7:0-40
Module not found: Error: Package path . is not exported from package ....../view/node_modules/#types/react (see exports field in ....../view/node_modules/#types/react/package.json)
ERROR in ./src/components/topics/TopicListDetail.js 7:0-51
Module not found: Error: Package path . is not exported from package ...../view/node_modules/#types/react (see exports field in ...../view/node_modules/#types/react/package.json)
both components are only imported in one place
import TopicList from "../../components/topics/TopicList";
import CourseList from "../../components/courses/CourseList";
Both follow the same conventions
function TopicList() {
let topicList = [];
for(let i = 0; i < topicList.length; i++) {
topicList.push(
<NavLink to={"/topic/" + i} className="" key={"popular-topic-" + i}>
<div className="">
<img src={"http://placeimg.com/100/100/people?" + i}
className="rounded-full hover:bg-sky-700" alt={"topic" + i} />
</div>
</NavLink>
);
}
return (
<div className="">
pretty tailwind css
</div>
)
}
export default TopicList;
I deleted my node_modules and package-lock.json and ran npm i. I am not seeing any errors in the js. I am not sure where to look at this point.
Here are where they are imported
import TopicList from "../../components/topics/TopicList";
import CourseList from "../../components/courses/CourseList";
function Home() {
return (
<Fragment>
<div className="box-border hover:box-content max-width: 640px; ">
<TopicList/>
<CourseList/>
</div>
</Fragment>
)
}
export default Home;
{
"name": "view",
"version": "0.1.0",
"private": true,
"dependencies": {
"#popperjs/core": "^2.11.5",
"#react-buddy/ide-toolbox": "^2.1.2",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.1.1",
"#testing-library/user-event": "^13.5.0",
"#types/react": "^18.0.10",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-minimal-side-navigation": "^1.9.2",
"react-redux": "^8.0.2",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"redux": "^4.2.0",
"redux-thunk": "^2.4.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#tailwindcss/typography": "^0.5.2",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.13",
"tailwindcss": "^3.0.24"
}
}
advice?
The issue for me ended up being image imports in the js file.
I had these mock valus:
import Course1 from "../../ui/course-1.png";
const [popularCourse] = useState([
{
ID: 1,
title: "Learning How to Create Beautiful Scenes in Illustrator in 60 minutes",
tutor: {
ID: 1,
name: "Lana Marandina",
username: "lanamara",
dp: "http://placeimg.com/100/100/people?tutor-" + 1,
},
duration: "82 min",
poster: Course1
},
Then add them to a list
var courseList = [];
for(let i = 0; i < popularCourse.length; i++){
courseList.push(
<NavLink to={"/course/" + popularCourse[i].ID} className="" key={"popular-course-" + i}>
<div className="rounded-lg p-2" style={{
background: "#e2e2e2 url(" + popularCourse[i].poster +") no-repeat center"
}}>
<div className="h-56">
<div className="">
<img src={popularCourse[i].tutor.dp} className="rounded-full" alt="popular-course"/>
</div>
</div>
The array path for poster was wrong, but the IDE gave me a very unhelpful error.

react : why does yarn start works and yarn build doesnt

I have a frontend served by a rest api and when i run yarn start i get a template page showing "loading" (the backend api is not running yet). But the problem is when i run yarn build, and then serve it with serve -s build or with a nginx i get an empty page. When i reload the page I have very briefly the content of the page (a fraction of second) and then a blank page with no error codes in the browser or the server requests.
I dont know where to start to troubleshoot this, could you help me define a method?
I have tried to build in containerized docker and outside containerized docker with serve -s build and it's the same: it doesnt come from docker.
The build folder contains all the necessary files and i dont have any errors on my page when loading in the browser or in the console where the nginx run. I will only put extracts relative to react as my nginx and docker are out of cause (i have tried everything outside nginx and docker with serve -s build)
This is my index.js :
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import App from "./components/App";
import 'bootstrap/dist/css/bootstrap.css';
ReactDOM.render(
<React.StrictMode>
<BrowserRouter basename="/">
<App/>
</BrowserRouter>
</React.StrictMode>,
document.getElementById("root")
);
And this is my App.js
import React from "react";
import { Route, Switch } from "react-router";
import { Container, Row } from "react-bootstrap";
import { BlogPage } from "./BlogPage";
import { PostPage } from "./PostPage";
function App() { return (
<Switch>
<Route path="/post/:id([\d]+)" component={PostPage}/>
<Route path="/tag/:tag/:page([\d]+)?" component={BlogPage}/>
<Route path="/:page([\d]+)?" component={BlogPage}/>
<Route path="*" component={() => (
<Container>
<Row>
<h1>404</h1>
</Row>
</Container> )}/>
</Switch>
); }
export default App;
this is my package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"homepage":".",
"dependencies": {
"#craco/craco": "^6.2.0",
"#headlessui/react": "^1.4.1",
"#heroicons/react": "^1.0.4",
"#tailwindcss/forms": "^0.3.3",
"#tailwindcss/typography": "^0.4.1",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"camelcase-keys": "^7.0.0",
"msw": "^0.35.0",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-responsive-carousel": "^3.2.21",
"react-router-dom": "^5.3.0",
"react-scripts": "^3.4.0",
"snakecase-keys": "^4.0.2",
"swr": "^1.0.0",
"tributejs": "^5.1.3",
"web-vitals": "^1.0.1",
"autoprefixer": "^9",
"storybook":"^6.5.6",
"postcss": "^7",
"tailwindcss": "npm:#tailwindcss/postcss7-compat",
"bootstrap":"^4.5.3",
"react-bootstrap":"^1.3.0",
"typescript":"^2.8.0",
"jquery":"^1.9.1",
"popper.js":"^1.16.1",
"axios":"^0.27.2",
"axios-mock-adapter":"^1.21.1",
"dompurify":"^2.3.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
},
"proxy": "http://localhost:8000",
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"jest": {
"resetMocks": false
},
"devDependencies": {
"autoprefixer": "^9",
"postcss": "^7",
"tailwindcss": "npm:#tailwindcss/postcss7-compat"
}
}
I have tried to remove the / in the path to static content in my index.html following this post Why won't React production build run on the browser? but it's the same.
I have tried to put "homepage":"." in my package.json but it's the same.
I have tried to put "start_url": "/" in my manifest.json but it's the same.
I have tried to put in my App.js but it's the same.
I have tried to remove "proxy": "http://localhost:8000" (which is there for api calls) from my package.json but it's the same.
I have tried to use HashRouter instead of BrowserRouter in my index.js but it's the same.
The fact it is loading a fraction of a second makes me think the problem is not the path in index.html
In this post: component is getting loaded for fraction of second in React
they say : "In React undefined and false values are not rendered. Since the data you're getting is from an async function the notifications component will be rendered briefly until initialized and then removed."
So in my case, in my components, i have an api call with axios in my ComponentDidMount sections. Would it be possible that the fact the data from the api call is undefined makes the build page to not render? But why would it render in yarn start and not in yarn build?
ComponentDidMount section :
componentDidMount() {
const pk = this.props.match.params.id;
axios.get(`/api/cms/pages/${pk}/`).then((res) => { const post = res.data;
this.setState({
post,
loading: false });
}) }
render() {
if (!this.state.loading) {
const post = this.state.post;
return (
<div className="col-md-8">
<img src={post.header_image_url.url} className="img-fluid rounded" alt=""
/>
<hr />
<h1>{post.title}</h1>
<hr />
<StreamField value={post.body} />
</div> );
}else{
return <div className="col-md-8">Loading...</div>;
} }
}
Thank you

ReactJS: Can't resolve '#babel/runtime/helpers/builtin/interopRequireDefault'

I followed the tutorial in online video but I got an error code like this:
Failed to compile
./node_modules/#material-ui/icons/Menu.js Module not found: Can't resolve '#babel/runtime/helpers/builtin/interopRequireDefault' inb'C:\LocalServer\static-page\node_modules\#material-ui\icons'
This error occurred during the build time and cannot be dismissed.
This is the code I write:
import React, {Component} from 'react';
import AppBar from '#material-ui/core/AppBar';
import ToolBar from '#material-ui/core/Toolbar';
import MenuIcon from '#material-ui/icons/Menu';
import IconButton from '#material-ui/core/IconButton';
class Header extends Component{
render(){
return(
<div>
<AppBar position="fixed" style={{backgroundColor:'#2f2f2f',boxShadow:'none',padding:'10px 0px'}}>
<ToolBar>
<div className="header_logo">
<div className="font_righteous header_logo_venue">The Venue</div>
<div className="header_logo_title">MUSICAL EVENTS</div>
</div>
<IconButton aria-label="Menu" color="inherit" onClick={()=>console.log('open')}>
<MenuIcon/>
</IconButton>
</ToolBar>
</AppBar>
</div>
);
}
}
export default Header
From the tutorial said that I should rename the directory from #material-ui/core/Menu on line 4 to #material-ui/icons/Menu. But when I revert back to #material-ui/core/Menu, the code is running, the button works, but no icon appeared.
But, from the tutorial shows that the program is running, with the icons appeared on it.
It has a white hamburger button icon on the header
This is the error code when I try to change core/Menu to icons/Menu
This is the result when I changed back to core/Menu
EDIT: The package.json I have right now:
{ "name": "static-page", "version": "0.1.0", "private": true, "dependencies": {
"#babel/runtime": "7.0.0-beta.55",
"#material-ui/core": "^1.4.3",
"#material-ui/icons": "^1.1.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-reveal": "^1.2.2",
"react-scripts": "2.1.3",
"react-scroll": "^1.7.9",
"react-slick": "^0.23.1" }, "scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject" }, "eslintConfig": {
"extends": "react-app" }, "browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all" ] }
Found a MUI issue which states the exact same problem. The solution is to upgrade to #material-ui/icons#1.1.1.
Since you have #material-ui/icons#^1.1.0 as a dependency, deleting node_modules and running npm install again should be sufficient.
Have a go and try:
npm add #babel/runtime
Or upgrade babel runtime:
"#babel/runtime": "7.0.0-beta.55"

Resources