@interface-db/react-common
v1.0.67
Published
InterfaceDB shared components for React and React Native
Readme
@interface-db/react-common
InterfaceDB shared components for React and React Native.
Maintained by InterfaceDB, based on the Instant source. See LICENSE.md and NOTICE for attribution.
Welcome to InterfaceDB’s React common components for React and React Native.
// ༼ つ ◕_◕ ༽つ Real-time Chat
// ----------------------------------
// * Updates instantly
// * Multiplayer
// * Works offline
import { init, id } from '@interface-db/react';
const db = init({
appId: process.env.NEXT_PUBLIC_APP_ID,
});
function Chat() {
// 1. Read
const { isLoading, error, data } = db.useQuery({
messages: {},
});
// 2. Write
const addMessage = (message) => {
db.transact(db.tx.messages[id()].update(message));
};
// 3. Render!
return <UI data={data} onAdd={addMessage} />;
}Get Started
Follow the getting started tutorial to set up a live React app in under 5 minutes!
Questions?
If you have any questions, feel free to drop us a line on our issue tracker
