I'm building a meeting management app using react. I want to add an end meeting button that exports a summary of the meeting that was stored in a state. Can I export the content of the state to an RTF file?
You can create an RTF using the Blob
object.
See the example below.
import React from "react";
class MyApp extends React.Component {
constructor(props) {
super(props);
this.state = {
summary: "Hello this is summary"
};
}
onEndMeeting = () => {
const element = document.createElement("a");
const file = new Blob([this.state.summary], { type: "text/plain" });
element.href = URL.createObjectURL(file);
element.download = "myFile.txt";
document.body.appendChild(element);
element.click();
};
render() {
return (
<div>
<button onClick={this.onEndMeeting}>End Meeting</button>
</div>
);
}
}
export default MyApp;
Stackblitz Demo: Click here