### Project Setup and Run Commands
Source: https://github.com/dhtmlx/react-scheduler-quick-start/blob/main/README.md
Provides the necessary bash commands to clone the repository, install dependencies, and start the React development server for the DHTMLX React Scheduler quick-start project.
```bash
git clone https://github.com/dhtmlx/react-scheduler-quick-start.git
cd react-scheduler-quick-start
yarn
yarn start
```
--------------------------------
### Install dhtmlxScheduler
Source: https://github.com/dhtmlx/react-scheduler-quick-start/blob/main/index.html
Install the dhtmlxScheduler component and its React wrapper using npm or yarn.
```bash
npm install dhtmlx-scheduler react-dhtmlx-scheduler
# or
yarn add dhtmlx-scheduler react-dhtmlx-scheduler
```
--------------------------------
### Basic Scheduler Setup in React
Source: https://github.com/dhtmlx/react-scheduler-quick-start/blob/main/index.html
Demonstrates how to import and render the dhtmlxScheduler component in a React functional component. It includes basic initialization and configuration.
```jsx
import React from 'react';
import { Scheduler } from 'react-dhtmlx-scheduler';
function App() {
const schedulerRef = React.useRef(null);
React.useEffect(() => {
const scheduler = schedulerRef.current;
if (scheduler) {
scheduler.init("scheduler_here", new Date(2023, 5, 15), "month");
scheduler.load("/data"); // Load data from a server
}
}, []);
return (
);
}
export default App;
```
--------------------------------
### Handling Scheduler Events
Source: https://github.com/dhtmlx/react-scheduler-quick-start/blob/main/index.html
Shows how to attach event listeners to the dhtmlxScheduler to respond to user interactions like adding or updating events. This example uses the `onEventSave` handler.
```jsx
import React from 'react';
import { Scheduler } from 'react-dhtmlx-scheduler';
function App() {
const schedulerRef = React.useRef(null);
const handleEventSave = (event, is_new, collection) => {
console.log('Event saved:', event);
// You can perform actions like sending data to a server here
return true; // Return true to allow saving
};
React.useEffect(() => {
const scheduler = schedulerRef.current;
if (scheduler) {
scheduler.init("scheduler_here", new Date(2023, 5, 15), "month");
scheduler.load("/data");
scheduler.attachEvent("onEventSave", handleEventSave);
}
}, []);
return (
);
}
export default App;
```
--------------------------------
### Initialize DHTMLX React Scheduler
Source: https://github.com/dhtmlx/react-scheduler-quick-start/blob/main/README.md
Demonstrates how to declaratively initialize the DHTMLX React Scheduler component in a React application. It shows importing necessary modules, defining event data, custom templates, and scheduler configuration, and passing them as props to the ReactScheduler component.
```ts
import { useRef } from 'react';
import ReactScheduler, { ReactSchedulerRef, Event, SchedulerTemplates, SchedulerConfig } from '@dhx/trial-react-scheduler';
import "@dhx/trial-react-scheduler/dist/react-scheduler.css";
export interface ReactSchedulerProps {
events: Event[];
activeView?: string;
activeDate?: Date;
}
export default function Scheduler({ events, activeView, activeDate }: ReactSchedulerProps) {
const schedulerRef = useRef(null);
const templates: SchedulerTemplates = {
event_class: (start: Date, end: Date, event: Event) => {
return event.classname || '';
}
};
const config: SchedulerConfig = {
first_hour: 6,
last_hour: 22,
hour_size_px: 60,
};
return (
{
console.log(`${entity} - ${action} - ${id}`, data);
}
}}
/>
);
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.