React integration for the Anchor reactive state management library.
npm install @anchorlib/react
For full documentation, visit Anchor for React
import { useAnchor } from '@anchorlib/react';
function Counter() {
const state = useAnchor({
count: 0,
user: {
name: 'John Doe',
email: 'john@example.com',
},
});
return (
<div>
<h1>Hello {state.user.name}</h1>
<p>Count: {state.count}</p>
<button onClick={() => state.count++}>Increment</button>
<button onClick={() => (state.user.name = 'Jane Doe')}>Change Name</button>
</div>
);
}
MIT