0.37.0 • Published 3 months ago

@tomic/react v0.37.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

@tomic/react: The Atomic Data library for React

A library for viewing and creating Atomic Data. Re-exports @tomic/lib.

demo + template on codesandbox!

docs

Setup

When initializing your App, initialize the store, which will contain all data. Wrap your App in a StoreContext.Provider, and pass the newly initialized store to it.

// App.tsx
import { StoreContext, Store } from "@tomic/react";
import { MyResource } from "./MyResource";

// The store contains all the data for
const store = new Store();

export default function App() {
  return (
    <StoreContext.Provider value={store}>
      <MyResource subject={subject} />
    </StoreContext.Provider>
  );
}

Now, your Store can be accessed in React's context, which you can use the atomic-react hooks!

Hooks

useResource, useString, useTitle

// Get the Resouce, and all its properties
const resource = useResource('https://atomicdata.dev/classes/Agent');
// The title takes either the Title, the Shortname or the URL of the resource
const title = useTitle(resource);
// All useValue / useString / useArray / useBoolean hooks have a getter and a setter.
// Use the setter in forms.
const [description, setDescription] = useString(resource, 'https://atomicdata.dev/properties/description');
// The current Agent is the signed in user, inluding their private key. This enables you to create Commits and update data on a server.
const [agent, setAgent] = useCurrentAgent();

return (
  <>
    <h1>{title}</h2>
    <textarea value={description} onChange={e => setDescription(e.target.value)} />
    <button type={button} onClick={resource.save}>Save & commit</button>
  </>
)
0.37.0

3 months ago

0.36.1

5 months ago

0.36.0

6 months ago

0.35.2

6 months ago

0.35.0

1 year ago

0.34.9

1 year ago

0.34.10

1 year ago

0.34.11

1 year ago

0.35.0-beta.0

1 year ago

0.34.12

1 year ago

0.35.0-beta.1

1 year ago

0.34.6

1 year ago

0.34.5

1 year ago

0.34.4

1 year ago

0.34.1-beta

1 year ago

0.34.2

1 year ago

0.34.1

1 year ago

0.34.0

2 years ago

0.34.8

1 year ago

0.34.7

1 year ago

0.34.1-beta3

1 year ago

0.34.1-beta2

1 year ago

0.32.1

2 years ago

0.32.0

2 years ago

0.31.0-beta7

2 years ago

0.31.0-beta8

2 years ago

0.31.0-beta6

2 years ago

0.31.0-beta3

2 years ago

0.31.0-beta4

2 years ago

0.31.0-beta1

2 years ago

0.31.0-beta2

2 years ago

0.31.0-beta28

2 years ago

0.31.0-beta27

2 years ago

0.31.0-beta25

2 years ago

0.31.0-beta23

2 years ago

0.31.0-beta19

2 years ago

0.31.0-beta18

2 years ago

0.31.0-beta16

2 years ago

0.31.0-beta14

2 years ago

0.31.0-beta12

2 years ago

0.31.2

2 years ago

0.31.0-beta21

2 years ago

0.31.0-beta62

2 years ago

0.31.1

2 years ago

0.31.0

2 years ago

0.31.0-beta10

2 years ago

0.30.9

2 years ago

0.30.8

2 years ago

0.30.7

2 years ago

0.30.6

2 years ago

0.30.5

2 years ago

0.30.4

2 years ago

0.30.3

2 years ago

0.30.2

2 years ago

0.30.1

2 years ago

0.30.0

2 years ago

0.29.0

2 years ago

0.28.4

2 years ago

0.29.2

2 years ago

0.28.3

2 years ago

0.29.1

2 years ago

0.27.2

3 years ago

0.27.1

3 years ago

0.27.0

3 years ago

0.26.1

3 years ago

0.26.0

3 years ago

0.24.3

3 years ago

0.24.0

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago