Comments (3)
Hello @Priyeshvaghela77,
when user is typing the data gets cleared out due to re-renders
You may consider storing a survey model within a state variable to prevent re-rendering when a component state is changed.
function SurveyComponent() {
const [surveyModel, setSurveyModel] = useState(null);
...
}
Please try storing a survey model within the state variable and let me know if this resolves the issue.
from survey-library.
Hello @JaneSjs,
We are already using a state for that.
This is what we are doing (sample code):
import { useEffect, useRef, useState } from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/defaultV2.min.css";
import * as SurveyCore from "survey-core";
export function LoadDynamicForm({ template }: { template: string }) {
const [survey, setSurvey] = useState<Model | null>(null);
useEffect(() => {
const surveyModel = new Model(JSON.parse(template));
setSurvey(surveyModel);
}, [template]);
return <>{survey && <Survey model={survey} />}</>;
}
package.json file:
"react": "^18.2.0",
"survey-creator-react": "^1.9.122",
"survey-react": "^1.9.122",
In this, we are using the survey object to get the questions, set some default values, populate based on some conditions etc.
For, first few seconds when the form is opened, when user writes anything it gets cleared out due to state re-renders.
I also tried using redux state for this. But the issue still persists with redux also
from survey-library.
Can you please tell me how/when the surveyjs stores the data user entered? As far as I observed it is done onBlur (when the input loses the focus)
I tried logging the survey.data but it's always cleared when the webapp is re-rendering
from survey-library.
Related Issues (20)
- Add file upload progress bar HOT 2
- Ranking: The "Select to Rank" feature stopped supporting keyboard navigation HOT 1
- [feature request] Progress Bar should include Preview step HOT 1
- Composite component: `onValueChanged` changes survey data with a delay
- [feature request] Resize/convert image before upload HOT 2
- Add lockedRowCount property into matrix dynamic
- Tagbox keyboard navigation issues.
- Matrix with Rating (keyboard navigation). Focus jumps to the next question after the first row immediately.
- Nested Panel preview - unexpected Edit button
- RegEx Validation doesn't display a validation error based on the specified regular expression HOT 1
- Add "Don't know" & "Refuse to answer" to Rating scale
- Is it possible to fetch the current page response when clicking on the Next Page?
- Custom questions: Prevent panels and pages from being registered as a specialized question type
- [Knockout / jQuery] The `completedHtml` property cannot be updated within the `onComplete` event handler
- Singlepage mode - pages are shown as panels in Preview HOT 1
- Image picker - The survey width mode doesn't change to responsive after setting column count that doesn't fix the container's static width value of 720px
- Checkboxes - A survey width mode is not switched to Responsive when the number of Checkbox columns is increased HOT 1
- Currency Input Mask - A decimal comma separator disappears when a currency value is copied to another field
- A preview takes more time to open after the upgrade
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from survey-library.