0.0.71 • Published 1 month ago

@ossy/cms-client-react v0.0.71

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

React bindings

To make it as easy as possible to use our cms we have created a library with react hooks you can use to fetch data.

Getting started

To use these hooks install the package @ossy/cms-client-react

npm install @ossy/cms-client-react

Then we simply need to wrap our app in a that will handle data storage and configuration for us. You will need the workspaceId for the workspace you want to fetch data from. The workspaceId can be found in the list of workspaces you have access to or in the url when you view the resources in the UI.

// App.jsx
import { WorkspaceProvider } from '@ossy/cms-client-react'
import { MyComponent } from './MyComponent.jsx'

export const App = () => (
  <WorkspaceProvider workspaceId="your-workspace-id">
    <MyComponent />
  </WorkspaceProvider>
)
// MyComponent.jsx
import { useResources } from '@ossy/cms-client-react'

export const MyComponent = () => {
  const { status, resources } = useResources('/folder/path/in/cms')

  return (
    <>
      { status === 'Error' && (
        <>Something went wrong</>
      )}

      { status === 'Loading' && (
        <>Loading...</>
      )}

      { status === 'Success' && (
        resources.map(resource => (
          <div key={resource.id}>
            {resource.name}
          </div>
        ))
      )}
    </>  
  )
}

Reference

useResources

const { status, resources } = useResources('/')

Parameters

  • path - Folder path in the cms UI

Returns

Returns an object containing

  • status - String value that indicates loading status. Can be used to show loading indicators or error screens. Possible values are: NotInitialized, Loading, Success, Error
  • resources - Array of resources, defaults to an empty array when loading is not Success

useResource

const { status, resource } = useResource('resourceId')

Parameters

  • resourceId - Id of the resource you want to fetch

Returns

Returns an object containing

  • status - String value that indicates loading status. Can be used to show loading indicators or error screens. Possible values are: NotInitialized, Loading, Success, Error
  • resource - The fetched resource, defaults to an empty object when status is not Success
0.0.71

1 month ago

0.0.70

1 month ago

0.0.69

1 month ago

0.0.65

2 months ago

0.0.66

2 months ago

0.0.67

2 months ago

0.0.64

3 months ago

0.0.63

10 months ago

0.0.62

11 months ago

0.0.60

12 months ago

0.0.61

12 months ago

0.0.59

12 months ago

0.0.58

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.51

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.45

2 years ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.32

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago