Home > Blockchain >  How to make react-valid code (add inner script)
How to make react-valid code (add inner script)

Time:11-08

I need to change this code to make it valid for React

<script src="https://securepay.tinkoff.ru/html/payForm/js/tinkoff_v2.js"></script>
<form name="TinkoffPayForm" onsubmit="pay(this); return false;">
  <input class="tinkoffPayRow" type="hidden" name="terminalkey" value="TinkoffBankTest">
  <input class="tinkoffPayRow" type="hidden" name="frame" value="true">
  <input class="tinkoffPayRow" type="hidden" name="language" value="ru"> 
    <input class="tinkoffPayRow" type="text" placeholder="Сумма заказа" name="amount" required>
    <input class="tinkoffPayRow" type="text" placeholder="Номер заказа" name="order">
    <input class="tinkoffPayRow" type="text" placeholder="Описание заказа" name="description">
    <input class="tinkoffPayRow" type="text" placeholder="ФИО плательщика" name="name">
    <input class="tinkoffPayRow" type="text" placeholder="E-mail" name="email">
    <input class="tinkoffPayRow" type="text" placeholder="Контактный телефон" name="phone">
    <input class="tinkoffPayRow" type="submit" value="Оплатить">
</form>

I added <script> to index.html, created <form> in React Component and add ref to form

I created const w = window as any and added

const onSubmit = () => {
    w.pay(form.current);
  }

But it didn't work

What I need to pass as argument to w.pay function?

CodePudding user response:

I solved the problem by adding dangerouslySetInnerHTML

  • Related