如何将来自 React 组件的值插入到文本区域值中

How to insert a value from a React component into textarea value

我试图在 textarea 值中插入一个组件的值,我从后端提取数据并在 GetAboutApp 组件中使用它,它在 <div> 等其他元素中工作正常或 <p> 例如,但是当在文本区域值 属性 中使用它时,它会给我 [object Object]

我的 GetAboutApp 组件代码:

import { useState, useEffect } from 'react';
import Axios from 'axios';

const GetAboutApp = () => {
  const [appDesc, setAppDesc] = useState('');

  useEffect(() => {
    const getAppDesc = async () => {
      const getAppDescUrl = 'http://dev.com:3001/getAppDesc';

      try {
        const response = await Axios.get(getAppDescUrl);
        setAppDesc(response.data);
      } catch (err) {
        console.error(err);
      }
    };
    getAppDesc();

    return () => setAppDesc(''); // cleanup: set the value to nothing
  }, []);

  return (
    <>
      {appDesc.DescRetrieved === 1
        ? appDesc.result[0].rest_app_about.length > DescLen
          ? appDesc.result[0].rest_app_about.slice(0, DescLen) + '...'
          : appDesc.result[0].rest_app_about
        : appDesc.message}
    </>
  );
};

export default GetAboutApp;

我的文本区域元素:

<textarea
                    name='aboutDescription'
                  id='aboutDescription'
                  defaultvalue={<GetAboutApp />}
                  minLength={MIN_DESC_LENGTH}
                  maxLength={MAX_DESC_LENGTH}
                  onChange={(e) => setAppDesc(e.target.value.trim())}
                  onKeyUp={(e) => {
                    const target = e.target.value.trim();

                    if (target.length > 0 && target.length < MIN_DESC_LENGTH) {
                      if (descErr)
                          descErr.textContent = `desc can't be less than ${MIN_DESC_LENGTH}`;
                      } else if (target.length > MAX_DESC_LENGTH) {
                        if (descErr)
                          descErr.textContent = `desc can't be more than ${MAX_DESC_LENGTH} character`;
                      } else {
                        if (descErr) descErr.textContent = '';
                      }
                    }}
                    required
                  ></textarea>

我的问题是如何在文本区域内呈现从组件返回的内容,或者是否有任何方法或技巧来实现这一点?

您需要在