mirror of
https://github.com/morten-olsen/react-native-debug-console.git
synced 2026-02-08 00:36:26 +01:00
V2 (#1)
This commit is contained in:
18
packages/lib/src/components/data/log.js
Normal file
18
packages/lib/src/components/data/log.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const useLog = (provider) => {
|
||||
const [logs, setLogs] = useState([]);
|
||||
useEffect(() => {
|
||||
const update = (newLogs) => {
|
||||
setLogs([...newLogs]);
|
||||
}
|
||||
provider.listen(update);
|
||||
|
||||
return () => {
|
||||
provider.unlisten(update);
|
||||
}
|
||||
}, []);
|
||||
return logs;
|
||||
};
|
||||
|
||||
export default useLog;
|
||||
Reference in New Issue
Block a user