open-index/open-npm huggingface dataset:
npm package: @railtownai/react
Description: React components that integrate with Railtown AI
Latest version: 2.0.29

# Railtown AI for React apps

Railtown AI root cause analysis for React apps.

## Getting Started

1. Sign up for a free account at [railtown.ai](https://railtown.ai).
1. Copy your Railtown API Token from the Project Configuration page
1. Install the package: `npm install --save @railtownai/react` or `yarn add @railtownai/react`
1. Follow the instructions below to integrate Railtown AI into your React app(s)

## Installation

```tsx
// main.tsx or index.tsx
import React from "react";
import * as RailtownAI from "@railtownai/react";

RailtownAI.install({
  token: YOUR_RAILTOWN_TOKEN,
  userProperties: {
    ignoreErrors: ["Error Message", /Exact Error Message/],
  },
});

function App() {
  return (
    <>
      <h1>Hello Railtown AI!</h1>
      <RailtownAI.ErrorBoundary fallback={<div>This is a fallback to the error</div>}>
        <SomeErroneousComponent />
      </RailtownAI.ErrorBoundary>
    </>
  );
}

const container = document.getElementById("app");
const root = ReactDOM.createRoot(container);
root.render(<App />);
```

## Usage with useLogger()

```tsx
// UserList.tsx
import React from "react";
import { useLogger } from "@railtownai/react";

const UserList = (props) => {
  const logger = useLogger();
  const [users, setUsers] = React.useState([]);

  useEffect(() => {
    (async () => {
      try {
        const response = await fetch("https://jsonplaceholder.typicode.com/users");
        const users = await response.json();
        setUsers(users);
      } catch (error) {
        logger.error(error);
      }
    })();
  }, []);

  return (
    <>
      <ul>
        {users.map((user) => (
          <li key={user.id}>{user.name}</li>
        ))}
      </ul>
    </>
  );
};
export { UserList };
```