Skip to content

Commit 84e2aa4

Browse files
hlomzikcursoragent
andauthored
docs: BROS-782: Add viewState documentation for ReactCode tag (#9332)
Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: hlomzik <hlomzik@users.noreply.github.com>
1 parent 93e1ce0 commit 84e2aa4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

docs/source/tags/reactcode.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Your React component receives these props from Label Studio:
121121
- **`addRegion`**: Function to create new regions
122122
- **`regions`**: Array of all existing regions for this tag
123123
- **`data`**: The task data referenced in the `data` parameter
124+
- **`viewState`**: Object containing current view/UI state information
124125

125126
#### `addRegion(value, extraData = {})`
126127

@@ -164,6 +165,39 @@ region.update({ ...region.value, status: 'updated' });
164165
region.delete();
165166
```
166167

168+
#### `viewState`
169+
170+
Object containing current view/UI state information for conditional rendering.
171+
172+
**Properties:**
173+
- **`currentScreen`**: `"quick_view" | "side_by_side" | "label_stream" | "review_stream"` - Current screen context
174+
- `"review_stream"`: Review mode (reviewer interface)
175+
- `"label_stream"`: Label stream mode (annotator streaming)
176+
- `"side_by_side"`: View all annotations mode (comparing annotations)
177+
- `"quick_view"`: Single task view (default)
178+
- **`darkMode`**: `boolean` - Whether the application is currently in dark mode
179+
180+
**Example:**
181+
```javascript
182+
function MyComponent({ React, addRegion, regions, data, viewState }) {
183+
const { currentScreen, darkMode } = viewState;
184+
185+
// Conditional rendering based on screen
186+
const isReviewing = currentScreen === "review_stream";
187+
188+
// Apply dark mode styles
189+
const containerStyle = {
190+
backgroundColor: darkMode ? '#1a1a1a' : '#ffffff',
191+
color: darkMode ? '#e5e5e5' : '#333333',
192+
};
193+
194+
return React.createElement('div', { style: containerStyle },
195+
isReviewing && React.createElement('p', null, 'Review Mode Active'),
196+
// ... rest of component
197+
);
198+
}
199+
```
200+
167201
## Output format for regions
168202

169203
Regions created with `ReactCode` follow Label Studio's standard format:

0 commit comments

Comments
 (0)