1.1.0 • Published 1 year ago

react-native-debug-on-the-fly v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-debug-on-the-fly

Tool created to assist in debugging react native applications

Installation

npm install react-native-debug-on-the-fly

Usage

Add the DOTF provider on top level of your app

import { DOTFProvider } from 'react-native-debug-on-the-fly';


//...
    <DOTFProvider enabled>
      <App />
    </DOTFProvider>
//...
}

To send logs use the pushLog function

import * as React from 'react';
import { StyleSheet, View, Text, Button } from 'react-native';
import { useDOTF } from 'react-native-debug-on-the-fly';

const Content = () => {
  const { pushLog, clear, logs } = useDOTF();
  return (
    <View style={styles.container}>
      <Text style={styles.title}>My app</Text>
      <Button
        title="Send log 1"
        onPress={() =>
          pushLog(
            JSON.stringify(
              { foo: 'bar', bar: 'foo', obj: { foo: 'bar' } },
              null,
              2
            )
          )
        }
      />
      <Button
        title="Send log 2"
        onPress={() => pushLog(`log ${Math.floor(Math.random() * 100)}`)}
      />
    </View>
  );
};

Table of props

Provider

PropertyTypeDescription
enabledbooleanIndicates if the tool is enabled and will receive logs. When false, the logs are not stored and the tool is not visible

Hook

PropertyTypeDescription
logs{time: string, content: string}[]List of logs
pushLog() => voidFunction that adds the log to the list
clear() => voidClear the log list

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.0

1 year ago