parent
0e50448477
commit
0201621d66
@ -1,12 +1,21 @@ |
||||
import React from 'react' |
||||
import React, { useEffect, useState } from 'react' |
||||
import { useBehaviorSubject } from './usesubscribe/index' |
||||
import { client } from './app' |
||||
|
||||
interface loggerProps { |
||||
|
||||
append: boolean |
||||
} |
||||
|
||||
export const Logger: React.FC<loggerProps> = ({}) => { |
||||
export const Logger: React.FC<loggerProps> = (props) => { |
||||
const log = useBehaviorSubject(client.feedback) |
||||
return (<div id='log'>{typeof log === 'string' ? log : JSON.stringify(log)}</div>) |
||||
const [value, setValue] = useState<string>('') |
||||
|
||||
useEffect(() => { |
||||
setValue(value => { |
||||
const addValue = typeof log === 'string' ? log : JSON.stringify(log) |
||||
return props.append ? `${value} ${addValue}` : addValue |
||||
}) |
||||
}, [log]) |
||||
|
||||
return (<div id='log'>{value}</div>) |
||||
} |
||||
|
Loading…
Reference in new issue