import React from 'react' ; export const useLog = ( ) => { const [ log , internalSetLog ] = React . useState ( '' ) ; const logRef = React . useRef ( '' ) ; const appendToLog = ( value ) => { const newText = logRef . current ? `${ logRef . current }\n${ value } ` : `${ value } ` ; setLog ( newText ) ; } ; const setLog = ( content ) => { if ( content !== undefined && content !== null ) { internalSetLog ( content ) ; logRef . current = content ; } } ; return { log , appendToLog , logRef , setLog } ; } ;