Answer the question
In order to leave comments, you need to log in
How to work with VK widgets in react spa?
Good afternoon. I can’t figure out how to connect the VK widget in react spa.
For example, VK provides the widget code:
<script type="text/javascript" src="//vk.com/js/api/openapi.js?150"></script>
<!-- VK Widget -->
<div id="vk_allow_messages_from_community"></div>
<script type="text/javascript">
VK.Widgets.AllowMessagesFromCommunity("vk_allow_messages_from_community", {height: 30}, 2158488);
</script>
<script type="text/javascript" src="//vk.com/js/api/openapi.js?150"></script>
VK.Widgets.AllowMessagesFromCommunity("vk_allow_messages_from_community", {height: 30}, 2158488);
VK.Observer.subscribe("widgets.allowMessagesFromCommunity.allowed", function f(userId) {
console.log(userId);
});
VK.Observer.subscribe("widgets.allowMessagesFromCommunity.denied", function f(userId) {
console.log(userId);
});
Answer the question
In order to leave comments, you need to log in
Inserting code into a component results in a build error (in principle, it is clear why):
'VK' is not defined no-undef
/* global VK */
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question