Skip to content

Counter example

This example shows state, native layout, text, and a press event.

import './App.css';
import { useState } from 'react';
import { Text, View } from '@symbiote-native/react';
export default function App() {
const [count, setCount] = useState(0);
return (
<View className="root" onPress={() => setCount(value => value + 1)}>
<Text className="text">Count is {count}</Text>
</View>
);
}
App.css
.root { flex: 1; align-items: center; justify-content: center; }
.text { font-size: 24px; }
Concern React Vue Angular Svelte
State useState() ref() plain class field $state() rune
Press event onPress directly on View @press directly on View (press) on a Pressable wrapper onPress directly on View
Styling className="root" + App.css class="root" + SFC <style> class="root" + app.css class="root" + component <style>
Native path shared engine shared engine shared engine shared engine

View itself carries onPress/onPressIn/onPressOut — React, Vue, and Svelte’s simplest counter reaches for it directly rather than wrapping in Pressable. Angular’s counter uses Pressable here since its non-function-children form is the idiomatic starting point on that adapter; either works on every adapter (see the Pressable example). StyleSheet.create works identically to a CSS class if you’d rather keep style objects inline — see the Styling guide.