我有以下内容:
export default (message, callback) => {
const modal = document.createElement('div')
document.body.appendChild(modal)
const withCleanup = (answer) => {
ReactDOM.unmountComponentAtNode(modal)
document.body.removeChild(modal)
callback(answer)
};
ReactDOM.render(
<Modal>
<header>Unsaved changes</header>
<p>
{message.message}
</p>
<Alert className="isError" />
<div className="modal__buttons-wrapper">
<Button onClick={() => withCleanup(true)}>Leave with unsaved changes</Button>
<Button onClick={() => withCleanup(false)}>Cancel</Button>
</div>
</Modal>,
modal
)
};
<Prompt message={'alex'} when />
有没有办法像这样传递对象进行翻译?
我尝试过:
const message = {
title: 'title',
message: 'message'
}
<Prompt message={message} when />
但它坏了。