国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

warning: React does not recognize the xxx prop on a DOM element

這篇具有很好參考價值的文章主要介紹了warning: React does not recognize the xxx prop on a DOM element。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

warning: React does not recognize the xxx prop on a DOM element

歡迎使用Markdown編輯器

1、錯誤提示

Warning: React does not recognize the disableValue prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase disablevalue instead. If you accidentally passed it from a parent component, remove it from the DOM element

2、分析原因

這是React不能識別dom元素上的非標(biāo)準(zhǔn)attribute報出的警告,最終的渲染結(jié)果中React會移除這些非標(biāo)準(zhǔn)的attribute。

const MyCheckboxGroup: React.FC<MyCheckboxGroupProps> = props => {
  const { data, value, onChange, style, disableValue } = props;
 
  useEffect(()=>{
    onChange?.(value);
  }, [value])
 
  return (
    <Checkbox.Group
      {...props}
      value={value}
      onChange={ onChange}
      style={style || {}}
    >
      {Object.getOwnPropertyNames(data).map((item: any, index: any) => (
        <Checkbox value={Number.parseInt(item, 10).toString()} style={{ marginLeft: 0 }} disabled={disableValue?.includes(item)} key={index}>
          {
            typeof data[item] === 'string'
              ? data[item]
              : data[item]?.text
          }
        </Checkbox>
      ))}
    </Checkbox.Group>
  );
};

3、解決

可以使用other接收屬性參數(shù),僅將other屬性參數(shù)傳遞給子組件或?qū)?yīng)的dom,自定義屬性只組件自己使用。文章來源地址http://www.zghlxwxcb.cn/news/detail-763756.html

const MyCheckboxGroup: React.FC<MyCheckboxGroupProps> = props => {
  const { data, value, onChange, style, disableValue, ...other } = props;
 
  useEffect(()=>{
    onChange?.(value);
  }, [value])
 
  return (
    <Checkbox.Group
      {...other}
      value={value}
      onChange={ onChange}
      style={style || {}}
    >
      {Object.getOwnPropertyNames(data).map((item: any, index: any) => (
        <Checkbox value={Number.parseInt(item, 10).toString()} style={{ marginLeft: 0 }} disabled={disableValue?.includes(item)} key={index}>
          {
            typeof data[item] === 'string'
              ? data[item]
              : data[item]?.text
          }
        </Checkbox>
      ))}
    </Checkbox.Group>
  );

到了這里,關(guān)于warning: React does not recognize the xxx prop on a DOM element的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Vue.js報錯問題解決:[Vue warn]: Error in v-on handler: “ReferenceError: XXX is not defined“.

    Vue.js報錯問題解決:[Vue warn]: Error in v-on handler: “ReferenceError: XXX is not defined“.

    代碼: 報錯信息: 原因:count 忘加 this 了。。。 1、2

    2024年02月13日
    瀏覽(31)
  • npm WARN cli npm vxxx does not support Node.js vxxx. This version of npm supports the following

    npm 與 node 的版本不匹配,如果不想切換node,將npm卸載再安裝即可 npm與node版本匹配查看 卸載npm npm uninstall npm -g 安裝指定版本的npm npm install npm@{版本號} -g 示例: npm install npm@5.6.0 -g 安裝完成之后,使用命令查看版本 npm --version 建議不要使用cnpm安裝,會有各種莫名其妙的bug出

    2024年02月04日
    瀏覽(47)
  • 關(guān)于JS中的一個[Vue warn]: Property “xxx“ was accessed during render but is not defined on instance 小問題

    關(guān)于JS中的一個[Vue warn]: Property “xxx“ was accessed during render but is not defined on instance 小問題

    作為一個Java Script的初學(xué)者,以此記錄做小練習(xí)時途中遇到的一點點小問題。 在網(wǎng)上找了很多關(guān)于無法找到“xxx”實例的消息,但是要么是太過于高級亦或者太過于不想關(guān)的例子,java與前端相關(guān)的js技術(shù)現(xiàn)在都是用VUE3來實現(xiàn),以下只是單獨抽出來一個js里的小練習(xí)里遇到的小

    2024年02月12日
    瀏覽(29)
  • 【BUG解決】sudo apt-get update 報錯 E: The repository ‘http://xxx Release‘ does not have a Release file.

    【BUG解決】sudo apt-get update 報錯 E: The repository ‘http://xxx Release‘ does not have a Release file.

    前兩天在虛擬機Vmware中安裝了Ubuntu18.04操作系統(tǒng),因為需要安裝其他工具。所以想著執(zhí)行命令 更新一下系統(tǒng),以便進行安裝。結(jié)果出現(xiàn) “E: The repository ‘http://xxx Release‘ does not have a Release file.” 以及 “E: Problem executing scripts APT::Update::Post-Invoke-Success \\\'if /usr/bin/test -w /var/cache

    2023年04月10日
    瀏覽(24)
  • [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent..

    [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent..

    ?錯誤:[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop\\\'s value. Prop being mutated: \\\"value\\\". 譯文:[Vue警告]:避免直接改變prop,因為每當(dāng)父組件重新呈現(xiàn)時,該值將被覆蓋。相反,應(yīng)該使用基于

    2024年02月12日
    瀏覽(19)
  • [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c

    [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c

    報錯翻譯:避免直接更改一個prop,因為每當(dāng)父組件重新渲染時,該值都會被覆蓋。相反,應(yīng)使用基于prop值的數(shù)據(jù)或計算屬性。正在更改的prop:“activeId” 解決辦法,使用基于prop的值,即把名為activeId的prop的值放在另一個變量中,對那個變量進行修改,不修改activeId。 1、實

    2024年02月03日
    瀏覽(30)
  • 解決WARNING: /opt/hadoop-3.1.1/logs does not exist. Creating.

    解決WARNING: /opt/hadoop-3.1.1/logs does not exist. Creating.

    在啟動Hadoop集群的過程中 在三個節(jié)點上啟動journalnode 命令如下: hdfs --daemon start journalnode 出現(xiàn)錯誤: WARNING: /opt/hadoop-3.1.1/logs does not exist. Creating. 解決方法: 進入安裝hadoop的目錄,我這里是/opt ?然后重新運行 hdfs --daemon start journalnode 結(jié)果如下 ?

    2024年02月12日
    瀏覽(20)
  • Java package xxx does not exist問題解決

    package org.redisson.api does not exist 1、pom.xml增加了redisson的maven依賴,但是沒有使用git提交代碼,導(dǎo)致測試環(huán)境報錯。 解決辦法:使用git提交代碼即可。 旭東怪的個人空間-旭東怪個人主頁-嗶哩嗶哩視頻 嗶哩嗶哩旭東怪的個人空間,提供旭東怪分享的視頻、音頻、文章、動態(tài)、收

    2024年02月11日
    瀏覽(24)
  • ssh : The term ‘ssh‘ is not recognized as the name of a cmdlet, function, script file, or opera

    ssh : The term ‘ssh‘ is not recognized as the name of a cmdlet, function, script file, or opera

    廢了很長時間才解決這問腿。在PowerShell中輸入ssh報: ssh : The term ‘ssh’ is not recognized as the name of a cmdlet, function, script file, or operable programssh:術(shù)語“ssh”未被識別為 cmdlet、函數(shù)、腳本文件或可運行程序的名稱。 復(fù)盤一下是問題是因為裝hightec,需要裝java,配置java環(huán)境變量,

    2024年02月07日
    瀏覽(21)
  • 消除Flutter doctor的警告Warning: `dart` on your path resolves to xxx/bin/dart

    消除Flutter doctor的警告Warning: `dart` on your path resolves to xxx/bin/dart

    最新更新了Flutter SDK到最新版本,然后使用 doctor 命令檢查環(huán)境發(fā)現(xiàn)以下警告. Warning: dart on your path resolves to /usr/local/Cellar/dart/2.13.3/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/wangyang/Developer/develop_env/flutter_3.7.9. Consider adding /Users/wangyang/Developer/develop_env/flutter

    2024年02月11日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包