Hi,
This is giving me a headache.
I am trying to make the Scheduler work with a react intranet I am working on.
Thus - the scheduler is a part of a react portal - and should be available to the user clicking on a menu item.
The problem is that when the sheduler is loaded first time, everything works ok. But if I then try to update the state in the component using the scheduler - i get an "Converting circular structure to JSON" error. This error only occurs if I use listeners in the scheduler (which I obviously have to). When I comment out the listeners - everything is ok.
I know it is tough to answer this without seeing all the code, but if you have any ideas that might put me in the right direction - it would be great!
Thank you.
Support Forum
My Booking Component:
import React from "react";
//Scheduler stuff
import { BryntumScheduler, helperString } from 'bryntum-react-shared';
import '../../../node_modules/bryntum-scheduler/scheduler.stockholm.css';
import '../../../node_modules/bryntum-react-shared/resources/shared.scss'
const staff = [
{ 'id' : 1, 'name' : 'Arcady', 'role' : 'Montør' },
{ 'id' : 2, 'name' : 'Dave', 'role' : 'Montør' },
{ 'id' : 3, 'name' : 'Henrik', 'role' : 'Lærling'},
{ 'id' : 4, 'name' : 'Mattis', 'role' : 'CTO' }
],
entries = [
{
resourceId : 1,
startDate : "2019-08-16 10:00",
endDate : "2019-08-16 14:00",
name : "Reklamasjon",
location : "Kunde Nr. 39406",
eventType : "Reklamasjon",
iconCls : "b-fa b-fa-calendar",
eventColor : "red"
},
{
resourceId : 2,
startDate : "2019-08-16 12:00",
endDate : "2019-08-16 14:00",
name : "Befaring",
location : "Kunde Nr. 39406",
eventType : "Befaring",
iconCls : "b-fa b-fa-calendar",
eventColor : "blue"
},
{
resourceId : 3,
startDate : "2019-08-16 13:00",
endDate : "2019-08-16 15:00",
name : "Koble til platetopp",
location : "Kunde Nr. 39406",
eventType : "Jobb",
iconCls : "b-fa b-fa-calendar",
eventColor : "green"
},
];
class Booking extends React.Component {
constructor(props) {
super(props);
this.state = {
isLoaded: false,
barMargin : 2,
selectedEvent : '',
};
}
componentDidCatch(error, info) {
//window.location.href = "/admin/booking"; //Crazy dirty code to prevent page from crashing when clickin booking menu item twice
}
render = () => {
var today = new Date();
var startDay = new Date();
var endDay = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
startDay = new Date(yyyy, mm-1, dd, 7);
endDay = new Date(yyyy, mm-1, dd, 23);
return (
<div className="content">
<BryntumScheduler
ref={'scheduler'}
// Make grid grow to fit rows
autoHeight={true}
// Initial row height
barMargin={this.state.barMargin}
startDate={startDay}
endDate={endDay}
resources = {staff}
events = {entries}
listeners={{
beforeEventSave ({source, eventRecord, resourceRecords , values }){
console.log('BEFORE EVENT SAVE')
switch(values.eventType) {
case 'Jobb':
eventRecord.eventColor = 'green';
eventRecord.iconCls = 'b-fa b-fa-calendar';
break;
case 'Reklamasjon':
eventRecord.eventColor = 'red';
break;
case 'Befaring':
eventRecord.eventColor = 'blue';
break;
case 'Interntid':
eventRecord.eventColor = 'gray';
break;
case 'Ferie':
eventRecord.eventColor = 'yellow';
break;
default:
}
},
beforeEventEdit ({source, eventRecord }){
console.log('BEFORE EVENT EDIT');
},
beforeEventDelete ({source, eventRecord }){
console.log('BEFORE EVENT DELETE');
},
eventclick ({source}) {
console.log("EVENT CLICK")
},
afterEventDrop ({source}) {
console.log("AFTER EVENT DROP");
},
beforeEventDropFinalize ({source}) {
console.log("BEFORE EVENT DROP FINALIZE") //show confirmation popup
},
beforeeventresizefinalize : function(data) {
// Save reference to context to be able to finalize drop operation after user clicks yes/no button.
console.log("BEFORE EVENT REZISE")
console.log(data)
this.setState({
barMargin: 10
})
}.bind(this)
}}
features={{
eventContextMenu : {
items : {
deleteEvent : false
}
},
eventEdit : {
extraItems : [
{
type : 'combo',
name : 'eventType',
label : 'Type',
index : 1,
items : ['Jobb', 'Reklamasjon', 'Befaring', 'Interntid', 'Ferie' ]
},
{
type : 'customer',
name : 'customer',
label: 'Adresse',
index: 2,
},
{
type : 'text',
name : 'location',
label: 'Adresse',
index: 3,
},
{
type : 'combo',
name : 'paymenttype',
label : 'Payment',
value : 'Card',
index : 4,
items : ['Card', 'Invoice' ]
},
]
}
}}
// Columns in scheduler
columns={[
{
type : 'resourceInfo',
imagePath : '../users/',
text : 'Employee',
width : 130
},
]}
// onEventSelectionChange={this.handleSelectionChange}
/> {/* eo BryntumScheduler */}
</div>
)
}
}
export default Booking;
Hi,
I have now created a ripped version of the intranet I am working on. It demos the error -> When you are on the "Booking" page, then click either the "Booking" menu item, or the "User" menu in the left menu - it crashes. It should have the same behaviour as when on the "Calendar" page.
1. Unzip the files
2. Run npm install
3. Copy the "bryntum-react-shared" folder and the "bryntum-resources" folder from the "copy_to_node_modules" folder to node_modules folder.
4. npm start
The zip is 31MB, so I was not able to attach it here, please download at:
https://drive.google.com/drive/folders/11Pq6TwPobXj--VVZtYxqzpFKr-WAhHMN?usp=sharing
Thank you so much for looking at this!!!
I have now created a ripped version of the intranet I am working on. It demos the error -> When you are on the "Booking" page, then click either the "Booking" menu item, or the "User" menu in the left menu - it crashes. It should have the same behaviour as when on the "Calendar" page.
1. Unzip the files
2. Run npm install
3. Copy the "bryntum-react-shared" folder and the "bryntum-resources" folder from the "copy_to_node_modules" folder to node_modules folder.
4. npm start
The zip is 31MB, so I was not able to attach it here, please download at:
https://drive.google.com/drive/folders/11Pq6TwPobXj--VVZtYxqzpFKr-WAhHMN?usp=sharing
Thank you so much for looking at this!!!
Won't start for me:
mankz:intra_ripped mats$ npm start
> paper-dashboard-pro-react@1.1.0 start /Library/WebServer/Documents/intra_ripped
> react-scripts start
There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.
The react-scripts package provided by Create React App requires a dependency:
"eslint": "^5.16.0"
Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:
/Library/WebServer/Documents/node_modules/eslint (version: 4.13.1)
Manually installing incompatible versions is known to cause hard-to-debug issues.
If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That will permanently disable this message but you might encounter other issues.
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (https://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if /Library/WebServer/Documents/node_modules/eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed eslint.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! paper-dashboard-pro-react@1.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the paper-dashboard-pro-react@1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mats/.npm/_logs/2019-08-23T12_36_47_756Z-debug.log
mankz:intra_ripped mats$
Hi, Mattis.
I can suggest you this quick fix.
Open bryntum-react-shared/BryntumScheduler.js find shouldComponentUpdate(nextProps, nextState) method and add 'listeners' to excludeProps
Like this.
A ticket was created to update our demos.
https://app.assembla.com/spaces/bryntum/tickets/9114-react-app--using-listeners-cause-app-crash-on-checking-scheduler--39-s-state/details
I can suggest you this quick fix.
Open bryntum-react-shared/BryntumScheduler.js find shouldComponentUpdate(nextProps, nextState) method and add 'listeners' to excludeProps
Like this.
excludeProps = ['listeners', 'events', 'resources', 'eventsVersion', 'resourcesVersion', 'timeRanges', 'columns', 'adapter', 'ref', 'children', ...this.features];
https://app.assembla.com/spaces/bryntum/tickets/9114-react-app--using-listeners-cause-app-crash-on-checking-scheduler--39-s-state/details