简体   繁体   English

React-未知的道具`page_id` <div> 标签。 从元素中移除该道具

[英]React - Unknown prop `page_id` on <div> tag. Remove this prop from the element

I'm integrating Facebook's Customer Chat Plugin to my website. 我正在将Facebook的客户聊天插件集成到我的网站。 In the instructions it says: 在说明中说:

include a div with the following attributes in your HTML:
<div class="fb-customerchat"
 page_id="<PAGE_ID>"
 ref="<OPTIONAL_WEBHOOK_PARAM>">
</div>

When I did so (this is the React version) : 当我这样做时(这是React版本):

<div className="fb-customerchat"
 page_id="<PAGE_ID>"
 ref="<OPTIONAL_WEBHOOK_PARAM>">
</div>

... I got this error from React: Warning: Unknown prop page_id on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html ...我从React得到这个错误: Warning: Unknown prop on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html Warning: Unknown prop page_id on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html , and the customer chat plugin isn't shown at all (I can still find the HTML elements in the DOM tree). on <div> tag. Remove this prop from the element. For details, see https://reactjs.org/warnings/unknown-prop.html ,并且根本不显示客户聊天插件(我仍然可以在DOM树中找到HTML元素)。
I did some searching and it seems like React doesn't recognize the custom page_id attribute. 我做了一些搜索,似乎React无法识别自定义的page_id属性。 I tried changing it to data-page_id but it doesn't help. 我尝试将其更改为data-page_id但无济于事。
Have anyone encountered the same problem and how did you resolve it ? 有没有人遇到过同样的问题,您如何解决?

https://react-cn.github.io/react/docs/tags-and-attributes.html https://react-cn.github.io/react/docs/tags-and-attributes.html

Looks like page id is not supported. 似乎不支持页面ID。 Try using classID or just id 尝试使用classID或仅使用id

I found out that the Customer Chat Plugin needs an HTML element inserted into the DOM with the parameters specified. 我发现客户聊天插件需要使用指定的参数将HTML元素插入DOM。 With React, you're never passing in raw HTML, hence the error message. 使用React,您永远不会传递原始HTML,因此不会显示错误消息。 To resolve this, you can do either: 要解决此问题,您可以执行以下任一操作:
- insert the .fb-customerchat div directly to your HTML or -将.fb-customerchat div直接插入HTML或
- use this package: https://github.com/Yoctol/react-messenger-customer-chat which is a workaround for React -使用这个包: https : //github.com/Yoctol/react-messenger-customer-chat这是React的一种解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM