-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathSetTextMainButton.jsx
33 lines (29 loc) · 975 Bytes
/
SetTextMainButton.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from 'react';
import TelegramDetailedButton from "../../kit/DetailedButton/TelegramDetailedButton";
import {useTelegram} from "../../../hooks/useTelegram";
import TelegramMiniForm from "../../kit/MiniForm/TelegramMiniForm";
/**
* MainButton.setText(text) is a method to set the button text.
*
* @see https://core.telegram.org/bots/webapps#mainbutton
*/
const SetTextMainButton = () => {
const {webApp, executeArgumentMethod} = useTelegram()
const onSetText = (text) => {
executeArgumentMethod(
'MainButton.setText',
text,
() => webApp.MainButton.setText(text)
)
}
return (
<TelegramMiniForm
fieldlabel={'MainButton.setText(text)'}
fielddescription={'A method to set the button text.'}
fieldhint={`Enter button label`}
buttonlabel={'Execute'}
onSubmit={onSetText}
/>
);
};
export default SetTextMainButton;