---
title: Cancellation Survey
product: Form Library
description: Maximize customer feedback with this demo. Learn how to configure and run a cancellation survey in your JavaScript app in no time using the free SurveyJS Form Library.
framework: React
source: https://surveyjs.io/form-library/examples/how-to-configure-and-embed-cancellation-survey/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Cancellation Survey (React)

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyComponent from "./SurveyComponent";

const root = createRoot(document.getElementById("surveyElement"));
root.render(<SurveyComponent />);
```

### `src/json.js`

```js
export const json = {
  "title": "Cancellation Survey",
  "description":  "Thank you for using our service. We would highly appreciate if you would take the time to fill our cancellation survey. This would help us improve the service.",
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
     "type": "radiogroup",
     "name": "using_duration",
     "title": "How long have you been using the service?",
     "choices": [
      "Less than a month",
      "1-6 months",
      "7-12 months",
      "1-3 years",
      "Over 3 years"
     ]
    },
    {
     "type": "radiogroup",
     "name": "using_frequency",
     "title": "How often did you use the service?",
     "choices": [
      "Once a week",
      "2 or 3 times a month",
      "Once a month",
      "Less than once a month"
     ]
    },
    {
     "type": "radiogroup",
     "name": "cancel_reason",
     "title": "What was the main reason for cancelling the service?",
     "showOtherItem": true,
     "choices": [
      "No longer need it",
      "It didn't meet my needs",
      "Found a better alternative",
      "Found a cheaper alternative",
      "Quality was less than expected",
      "Ease of use was less than expected",
      "Access to the service was less than expected",
      "Customer service was less than expected"
     ]
    },
    {
     "type": "radiogroup",
     "name": "satisfaction",
     "title": "Overall, how satisfied were you with the service?",
     "choices": [
      "Very Satisfied",
      "Satisfied",
      "Neutral",
      "Unsatisfied",
      "Very Unsatisfied"
     ]
    },
    {
     "type": "matrix",
     "name": "future_using",
     "titleLocation": "hidden",
     "columns": [
      "Definitely",
      "Probably",
      "Not Sure",
      "Probably Not",
      "Definitely Not"
     ],
     "rows": [
      {
       "value": "use_in_future",
       "text": "Will you use our service in the future?"
      },
      {
       "value": "recommend",
       "text": "Will you recommend our service to others?"
      }
     ]
    },
    {
      "type": "comment",
      "name": "service_improvements",
      "title": "How can we improve our service?",
      "maxLength": 500
    }
   ]
  }
 ]
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/how-to-configure-and-embed-cancellation-survey/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/how-to-configure-and-embed-cancellation-survey/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/how-to-configure-and-embed-cancellation-survey/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/how-to-configure-and-embed-cancellation-survey/vanillajs.md)
