Skip to content

【textarea组件】textarea的value值为null或者不赋值时,placeholder动态设置值后,输入框显undefined #2644

Description

@MY729
import React, { useState } from 'react';
/**
 * 问题:textarea的value值为null或者不赋值时,placeholder动态设置值后,输入框显undefined
 * 复现步骤:
 * 1. textarea组件value初始值为null或者不赋值时
 * 2. 点击按钮设置placeholder值
 * 3. 输入框显undefined
 * 渠道:只有支付宝小程序复现
 */
const TextareaBug1 = (props) => {
  const [placeholderText, setPlaceholderText] = useState('');
  const [valuText, setValuText] = useState(null); // 或者useState()

  const styleObj = {
    background: 'rgb(91, 201, 192)',
    border: '1px #efefef solid',
    padding: '20px',
    marginBottom: '20px'
  }
  return (
    <>
      <view style={styleObj} onTap={() => setPlaceholderText('初始值')}>初始值</view>
      <view style={styleObj} onTap={() => setPlaceholderText('值111')}>值111</view>
      <textarea placeholder={placeholderText} value={valuText}/>
    </>
  );
};
export default TextareaBug1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions