Skip to content

Commit

Permalink
change devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
kacper-mikolajczak committed Jan 22, 2024
1 parent 62208ab commit cdfb944
Showing 1 changed file with 40 additions and 12 deletions.
52 changes: 40 additions & 12 deletions src/PERF.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
import React from 'react';
import {Text} from 'react-native';
import React, {useRef} from 'react';
import {Text, View} from 'react-native';
import Performance from 'react-native-performance';
import {startProfiling, stopProfiling} from 'react-native-release-profiler';

const onPress = () => {
const metrics = Performance.getEntries();
fetch('http://10.0.2.2:8080', {
method: 'POST',
body: JSON.stringify(metrics),
});
};
function SendDataButton() {
const onPress = () => {
const metrics = Performance.getEntries();
fetch('http://10.0.2.2:8080', {
method: 'POST',
body: JSON.stringify(metrics),
});
};
return <Text onPress={onPress}>devtools</Text>;
}

function ProfilingButton() {
const ref = useRef(null);
const active = useRef(false);
const onPress = () => {
if (active.current) {
stopProfiling(true);
active.current = false;
ref.current.setNativeProps({style: {backgroundColor: 'green'}});
} else {
startProfiling();
active.current = true;
ref.current.setNativeProps({style: {backgroundColor: 'red'}});
}
};

function PerfDevtools() {
return (
<Text
ref={ref}
onPress={onPress}
style={{position: 'absolute', bottom: 0, zIndex: 1000}}
style={{padding: 10, backgroundColor: 'green', opacity: 0.5}}
>
devtools
Profiling
</Text>
);
}

function PerfDevtools() {
return (
<View style={{position: 'absolute', bottom: 0, zIndex: 1000, flexDirection: 'row', gap: 20}}>
{/* <SendDataButton /> */}
<ProfilingButton />
</View>
);
}

const perf = {
marks: {
messageSent: '[SendMessage]Sent',
Expand Down

0 comments on commit cdfb944

Please sign in to comment.