Skip to content

Commit 016d978

Browse files
committed
update docs
1 parent 3093016 commit 016d978

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

docs/sdk/javascript/guide.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,29 +139,28 @@ unsubFeature()
139139

140140
### React integration
141141

142-
```typescript
143-
import { useEffect, useState } from 'react';
144-
145-
function useConfig<K extends keyof Configs>(name: K) {
146-
const [value, setValue] = useState(() => replane.get(name));
142+
For React applications, use the dedicated [`@replanejs/react`](/docs/sdk/react) package which provides optimized hooks and components:
147143

148-
useEffect(() => {
149-
return replane.subscribe(name, (config) => {
150-
setValue(config.value as Configs[K]);
151-
});
152-
}, [name]);
144+
```tsx
145+
import { ReplaneProvider, useConfig } from '@replanejs/react';
153146

154-
return value;
147+
function App() {
148+
return (
149+
<ReplaneProvider connection={connection}>
150+
<Dashboard />
151+
</ReplaneProvider>
152+
);
155153
}
156154

157-
// Usage
158-
function App() {
159-
const darkMode = useConfig('feature-dark-mode');
155+
function Dashboard() {
156+
const darkMode = useConfig<boolean>('feature-dark-mode');
160157

161158
return <div className={darkMode ? 'dark' : 'light'}>...</div>;
162159
}
163160
```
164161

162+
The React SDK handles subscriptions, re-renders, Suspense, and error boundaries automatically. See the [React SDK Guide](/docs/sdk/react/guide) for full documentation.
163+
165164
## Error handling
166165

167166
### Connection errors

0 commit comments

Comments
 (0)