Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async componentDidMount() {
window.addEventListener('resize', this.handleResize);
this.updateHeight();
this.updateWidth();
const { roomName } = this.props;
if (roomName) {
this.socket = io(`http://${window.location.hostname}:${process.env.PORT_WEBSOCKET || '1234'}`);
this.socket.on('activeUser', this.handleActiveUser);
this.y = await Y({
db: {
name: 'memory',
},
connector: {
name: 'websockets-client',
socket: this.socket,
// TODO: Will be solved in future https://github.com/y-js/y-websockets-server/commit/2c8588904a334631cb6f15d8434bb97064b59583#diff-e6a5b42b2f7a26c840607370aed5301a
room: encodeURIComponent(roomName),
},
share: {
textarea: 'Text',
},
});
this.y.share.textarea.bindCodeMirror(this.refEditor.current.editor);
this.socket.on('clientCursor', this.handleClientCursor);
}
componentDidMount() {
if (this.props.roomName) {
Y({
db: {
name: 'memory',
},
connector: {
name: 'websockets-client',
url: `http://${window.location.hostname}:1234`,
room: encodeURIComponent(this.props.roomName),
},
share: {
textarea: 'Text',
},
}).then((y) => {
this.y = y;
y.share.textarea.bindAce(this.editor.editor, { aceRequire });
});
}