mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
Merge pull request #12085 from ToolJet/hotfix/radio-default-issue-develop
[hotfix]: Expose proper default value on radiobutton component
This commit is contained in:
commit
938a308477
1 changed files with 3 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export const RadioButton = function RadioButton({
|
||||
|
|
@ -12,8 +12,8 @@ export const RadioButton = function RadioButton({
|
|||
darkMode,
|
||||
dataCy,
|
||||
}) {
|
||||
const isInitialRender = useRef(true);
|
||||
const { label, value, values, display_values } = properties;
|
||||
|
||||
const { visibility, disabledState, activeColor, boxShadow } = styles;
|
||||
const textColor = darkMode && styles.textColor === '#000' ? '#fff' : styles.textColor;
|
||||
const [checkedValue, setValue] = useState(() => value);
|
||||
|
|
@ -37,12 +37,6 @@ export const RadioButton = function RadioButton({
|
|||
fireEvent('onSelectionChange');
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isInitialRender.current) return;
|
||||
setExposedVariable('value', value);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const exposedVariables = {
|
||||
value: value,
|
||||
|
|
@ -51,9 +45,8 @@ export const RadioButton = function RadioButton({
|
|||
},
|
||||
};
|
||||
setExposedVariables(exposedVariables);
|
||||
isInitialRender.current = false;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [value]);
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Reference in a new issue