import { useHistory } from "react-router-dom";
function MyComponent() {
const history = useHistory();
function handleGoBack() {
const lastAction = history.action;
if (lastAction === "POP") {
console.log("Вы находитесь на первой странице");
} else {
history.goBack();
}
}
return (
<div>
<button onClick={handleGoBack}>Назад</button>
</div>
);
}
import { connect } from 'react-redux';
import { undo } from './canvasSlice';
class MyComponent extends React.Component {
handleClick = () => {
this.props.undo();
}
render() {
return (
<button onClick={this.handleClick}>Undo</button>
);
}
}
export default connect(null, { undo })(MyComponent)
import { useDispatch } from 'react-redux';
import { undo } from './canvasSlice';
function MyComponent() {
const dispatch = useDispatch();
const handleClick = () => {
dispatch(undo());
}
return (
<button onClick={handleClick}>Undo</button>
);
}
export default MyComponent
undo: async (state) => {
const { canvas, undoList, redoList } = state;
if (undoList.length && canvas) {
const dataURL = undoList.pop();
redoList.push(dataURL);
const img = new Image();
img.src = dataURL;
await img.decode();
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
} else if (canvas) {
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
console.log('Нет элементов для отката');
} else {
console.log('canvas is null');
}
}
On "Mail → All settings → Email clients" page check "Use a mail client to retrieve your Yandex mail - From the imap.yandex.com server via IMAP" and "IMAP authorization method - App passwords and OAuth tokens".
On "Account management" page in "Passwords and authorization" section select "Enable app passwords" and create new application password.
require 'path/to/PHPMailer/src/Exception.php';
require 'path/to/PHPMailer/src/PHPMailer.php';
require 'path/to/PHPMailer/src/SMTP.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
Например так:
А в целом писать код для своих нужд самому. Это не так уж и проблемно.