authscape 1.0.325 → 1.0.326

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -150,21 +150,31 @@ function AutoSaveTextField(_ref) {
150
150
  _useState2 = _slicedToArray(_useState, 2),
151
151
  text = _useState2[0],
152
152
  setText = _useState2[1];
153
+ var _useState3 = (0, _react.useState)(false),
154
+ _useState4 = _slicedToArray(_useState3, 2),
155
+ isComponentMounted = _useState4[0],
156
+ setComponentMounted = _useState4[1];
153
157
  (0, _react.useEffect)(function () {
154
- // Simulate saving text to a server or any storage mechanism
155
- // In a real-world scenario, you would send a request to a server to save the text
156
- // For this example, we'll just update the savedText state after 2 seconds
157
- var saveTimeout = setTimeout(function () {
158
- if (onChanged != null) {
159
- onChanged(text);
160
- }
161
- }, timeout);
158
+ // Set the componentMounted flag to true after the initial render
159
+ setComponentMounted(true);
160
+ }, []);
161
+ (0, _react.useEffect)(function () {
162
+ if (isComponentMounted) {
163
+ // Simulate saving text to a server or any storage mechanism
164
+ // In a real-world scenario, you would send a request to a server to save the text
165
+ // For this example, we'll just update the savedText state after 2 seconds
166
+ var saveTimeout = setTimeout(function () {
167
+ if (onChanged != null) {
168
+ onChanged(text);
169
+ }
170
+ }, timeout);
162
171
 
163
- // Clean up the timeout to avoid unnecessary saves if the text changes again
164
- return function () {
165
- return clearTimeout(saveTimeout);
166
- };
167
- }, [text]);
172
+ // Clean up the timeout to avoid unnecessary saves if the text changes again
173
+ return function () {
174
+ return clearTimeout(saveTimeout);
175
+ };
176
+ }
177
+ }, [text, isComponentMounted]);
168
178
  var handleTextChange = function handleTextChange(event) {
169
179
  var newText = event.target.value;
170
180
  setText(newText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.325",
3
+ "version": "1.0.326",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,21 +3,31 @@ import TextField from '@mui/material/TextField';
3
3
 
4
4
  export function AutoSaveTextField ({label = "", variant = "outlined", timeout = 2000, isMultiLine = false, rows = 1, fullWidth = false, onChanged = null}) {
5
5
  const [text, setText] = useState('');
6
+ const [isComponentMounted, setComponentMounted] = useState(false);
6
7
 
7
8
  useEffect(() => {
8
- // Simulate saving text to a server or any storage mechanism
9
- // In a real-world scenario, you would send a request to a server to save the text
10
- // For this example, we'll just update the savedText state after 2 seconds
11
- const saveTimeout = setTimeout(() => {
12
- if (onChanged != null)
13
- {
14
- onChanged(text);
15
- }
16
- }, timeout);
9
+ // Set the componentMounted flag to true after the initial render
10
+ setComponentMounted(true);
11
+ }, []);
17
12
 
18
- // Clean up the timeout to avoid unnecessary saves if the text changes again
19
- return () => clearTimeout(saveTimeout);
20
- }, [text]);
13
+ useEffect(() => {
14
+
15
+ if (isComponentMounted)
16
+ {
17
+ // Simulate saving text to a server or any storage mechanism
18
+ // In a real-world scenario, you would send a request to a server to save the text
19
+ // For this example, we'll just update the savedText state after 2 seconds
20
+ const saveTimeout = setTimeout(() => {
21
+ if (onChanged != null)
22
+ {
23
+ onChanged(text);
24
+ }
25
+ }, timeout);
26
+
27
+ // Clean up the timeout to avoid unnecessary saves if the text changes again
28
+ return () => clearTimeout(saveTimeout);
29
+ }
30
+ }, [text, isComponentMounted]);
21
31
 
22
32
  const handleTextChange = (event) => {
23
33
  const newText = event.target.value;