How to clear the view doc ?

I figured it

let transaction = view.state.update({
                changes: {
                    from: 0,
                    to: view.state.doc.length,
                    insert: ''
                }
            });
            view.dispatch(transaction);