Skip to content

Commit 0d8a6d9

Browse files
authored
Update README.md
1 parent ab757c2 commit 0d8a6d9

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22

33
This library makes it easy to use the [TalkJS](https://talkjs.com) pre-built chat UIs inside a React web application.
44

5-
`talkjs-react` encapsulates `talkjs`, the framework-independent ("vanilla") [TalkJS JavaScript SDK](https://talkjs.com/docs/Reference/JavaScript_Chat_SDK). It only provides React components for UI-related matters: For anything related to data manipulation, such as synchronizing user data, or creating and joining conversations, use the vanilla SDK.
5+
`@talkjs/react` encapsulates `talkjs`, the framework-independent ("vanilla") [TalkJS JavaScript SDK](https://talkjs.com/docs/Reference/JavaScript_Chat_SDK). It only provides React components for UI-related matters: For anything related to data manipulation, such as synchronizing user data, or creating and joining conversations, use the vanilla SDK.
66

77
TypeScript bindings are included.
88

99
## Experimental note
1010
This library is hot off the press. It provides a substantially faster way to get TalkJS going with React, but it may still have a few childhood quirks.
1111

12-
If you encounter any problems with `talkjs-react`, please open an issue. If you have a problem with TalkJS itself, or if you're not sure where the problem lies, it's better to open a chat with our support on https://talkjs.com/ (just open the chat widget). TalkJS support is staffed by engineers.
12+
If you encounter any problems with `@talkjs/react`, please open an issue. If you have a problem with TalkJS itself, or if you're not sure where the problem lies, it's better to open a chat with our support on https://talkjs.com/ (just open the chat widget). TalkJS support is staffed by engineers.
1313

1414
## Getting Started
1515

16-
Install both `talkjs-react` and the vanilla [TalkJS NPM package](https://www.npmjs.com/package/talkjs):
16+
Install both `@talkjs/react` and the vanilla [TalkJS NPM package](https://www.npmjs.com/package/talkjs):
1717

1818
```sh
19-
yarn add talkjs talkjs-react
19+
npm install talkjs @talkjs/react
20+
# or
21+
yarn add talkjs @talkjs/react
2022
```
2123

22-
`talkjs-react` is just a thin wrapper around `talkjs`. Notably, it is designed such that when you update to a new version of `talkjs` that exposes new options, methods or events, you can use these right away from the React components, without having to update `talkjs-react` (or wait for such an update to be published)
24+
`@talkjs/react` is just a thin wrapper around `talkjs`. Notably, it is designed such that when you update to a new version of `talkjs` that exposes new options, methods or events, you can use these right away from the React components, without having to update `@talkjs/react` (or wait for such an update to be published)
2325

2426
## Load a UI for existing chat data
2527

@@ -28,7 +30,7 @@ yarn add talkjs talkjs-react
2830
Wrap your main app components in a session:
2931

3032
```tsx
31-
import { Session } from "talkjs-react";
33+
import { Session } from "@talkjs/react";
3234

3335
//...
3436

@@ -46,7 +48,7 @@ The session encapsulates a connection to the TalkJS realtime infrastructure, and
4648
Anywhere inside the children of `<Session>` you can create a `<Chatbox>`, an `<Inbox>` or a `<Popup>`:
4749

4850
```tsx
49-
import { Chatbox } from "talkjs-react";
51+
import { Chatbox } from "@talkjs/react";
5052

5153
//...
5254

@@ -73,7 +75,7 @@ To create or update user data, just replace the `userId` prop by `syncUser`. Thi
7375

7476
```tsx
7577
import { useCallback } from "react";
76-
import { Session } from "talkjs-react";
78+
import { Session } from "@talkjs/react";
7779
import Talk from "talkjs";
7880

7981
//...
@@ -98,7 +100,7 @@ const syncUser = useCallback(
98100
</Session>;
99101
```
100102

101-
Note: you can't create `Talk.User` object before the TalkJS SDK has initialized. In vanilla JS you'd have to await `Talk.ready` promise for this, but `talkjs-react` ensures that you `syncUser` callback is only called after TalkJS is ready.
103+
Note: you can't create `Talk.User` object before the TalkJS SDK has initialized. In vanilla JS you'd have to await `Talk.ready` promise for this, but `@talkjs/react` ensures that your `syncUser` callback is only called after TalkJS is ready.
102104

103105
### 2. Create and join a conversation
104106

@@ -108,7 +110,7 @@ Just replace the `conversation` prop by a `syncConversation` callback, which wil
108110

109111
```tsx
110112
import { useCallback } from "react";
111-
import { Chatbox } from "talkjs-react";
113+
import { Chatbox } from "@talkjs/react";
112114
import Talk from "talkjs";
113115

114116
//...
@@ -194,7 +196,7 @@ If you need to do things with your
194196
In any child component of `<Session>` you can call the `useSession` hook to get the `Talk.Session` object:
195197

196198
```tsx
197-
import { useSession } from "talkjs-react";
199+
import { useSession } from "@talkjs/react";
198200

199201
function MyComponent(props) {
200202
const session = useSession(); // Talk.Session | undefined
@@ -213,7 +215,7 @@ since been destroyed. See the section on liveness below.
213215
### Using refs
214216

215217

216-
All `talkjs-react` components let you assign the underlying TalkJS object to a
218+
All `@talkjs/react` components let you assign the underlying TalkJS object to a
217219
ref:
218220

219221
```tsx
@@ -293,12 +295,12 @@ Should you want to contribute, please take note of the design notes below.
293295

294296
## Design notes
295297

296-
This library has been designed to be maximally forward-compatible with future TalkJS features. The `talkjs` package is a peer dependency, not a direct dependency, which means you can control which TalkJS version you want to be on. It also means you won't need to wait for a new version of `talkjs-react` to be published before you can get access to new TalkJS features.
298+
This library has been designed to be maximally forward-compatible with future TalkJS features. The `talkjs` package is a peer dependency, not a direct dependency, which means you can control which TalkJS version you want to be on. It also means you won't need to wait for a new version of `@talkjs/react` to be published before you can get access to new TalkJS features.
297299

298-
From our (TalkJS) perspective, it means we have a lower maintenance burden: we can ship new JS features without having to update (and test and verify) `talkjs-react`.
300+
From our (TalkJS) perspective, it means we have a lower maintenance burden: we can ship new JS features without having to update (and test and verify) `@talkjs/react`.
299301

300302
This works because vanilla TalkJS is fully backward compatible and has a very consistent design: all UI components are instantiated and mutated in the same way. The React components simply treats any prop that looks like an event (name starts with "on") like an event. Also, barring some props unique to the react components (such as `syncConversation`, `style` and `loadingComponent`), all remaining props are simply assumed to be valid options to pass to `createChatbox` and its sister methods.
301303

302-
This way, if TalkJS eg adds support for a new event or a new option, this will Just Work without updating `talkjs-react`. Modern TypeScript features (notably, [template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html)) let us do this in a fully type-safe manner: If you upgrade `talkjs`, then your invocations to `talkjs-react` components will allow new props.
304+
This way, if TalkJS eg adds support for a new event or a new option, this will Just Work without updating `@talkjs/react`. Modern TypeScript features (notably, [template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html)) let us do this in a fully type-safe manner: If you upgrade `talkjs`, then your invocations to `@talkjs/react` components will allow new props.
303305

304-
Any future changes should follow this same design: they should be maximally forward compatible.
306+
Any future changes should follow this same design: they should be maximally forward compatible.

0 commit comments

Comments
 (0)