mirror of
https://github.com/morten-olsen/react-native-debug-console.git
synced 2026-02-08 00:36:26 +01:00
20 lines
357 B
JavaScript
20 lines
357 B
JavaScript
import { useEffect, useState } from 'react';
|
|
import log from '../../log';
|
|
|
|
const useLog = () => {
|
|
const [logs, setLogs] = useState([]);
|
|
useEffect(() => {
|
|
const update = (newLogs) => {
|
|
setLogs([...newLogs]);
|
|
}
|
|
log.listen(update);
|
|
|
|
return () => {
|
|
log.unlisten(update);
|
|
}
|
|
}, []);
|
|
return logs;
|
|
};
|
|
|
|
export default useLog;
|