mirror of
https://github.com/NetEase/tango.git
synced 2026-08-28 17:41:30 +08:00
fix: render-setter expression value bug (#133)
* Create sync.yml * Update sync.yml * fix: render-setter expression value bug * ci: remove sync.yml
This commit is contained in:
@@ -173,7 +173,7 @@ class App extends React.Component {
|
||||
<FormilyFormItem name="select1" component="Select" label="表单项" />
|
||||
</FormilyForm>
|
||||
</Section>
|
||||
<Section title="原生 DOM" tid="section3">
|
||||
<Section title="原生 DOM" tid="section4">
|
||||
<div
|
||||
style={{
|
||||
border: "1px solid #ccc",
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { ActionSelect, InputCode } from '@music163/tango-ui';
|
||||
import { FormItemComponentProps } from '@music163/tango-setting-form';
|
||||
import { Box } from 'coral-system';
|
||||
import { value2expressionCode } from '@music163/tango-core';
|
||||
|
||||
interface IRenderOption {
|
||||
label: string;
|
||||
@@ -26,10 +27,11 @@ export function RenderSetter({
|
||||
options = [],
|
||||
fallbackOption,
|
||||
}: FormItemComponentProps & RenderSetterProps) {
|
||||
const [inputValue, setInputValue] = useState(value);
|
||||
|
||||
const [inputValue, setInputValue] = useState(() => {
|
||||
return value2expressionCode(value);
|
||||
});
|
||||
useEffect(() => {
|
||||
setInputValue(value);
|
||||
setInputValue(value2expressionCode(value));
|
||||
}, [value]);
|
||||
|
||||
const optionsMap = useMemo(() => {
|
||||
@@ -53,9 +55,9 @@ export function RenderSetter({
|
||||
return (
|
||||
<Box>
|
||||
<ActionSelect text={text} options={options} onSelect={onSelect} />
|
||||
{value && (
|
||||
{inputValue && (
|
||||
<InputCode
|
||||
value={value}
|
||||
value={inputValue}
|
||||
onChange={(val) => setInputValue(val)}
|
||||
onBlur={() => onChange(inputValue)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user