2.13.0 • Published 3 months ago

@themost/react v2.13.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 months ago

@themost/react

MOST Web Framework Logo

@themost-framework client library for react based on @themost/client

NPM GitHub top language License GitHub last commit GitHub Release Date

Install

npm install --save @themost/react

Usage

Create application data context

import React from 'react'
import { ReactDataContext } from '@themost/react'
export const context = React.createContext(new ReactDataContext('http://api.example.com/api/'))

where new ReactDataContext(string) is being used for defining the remote api server

and use context in any component e.g.

import React from 'react'
import { context } from './context'

interface CustomersState {
  items: any[]
}

export default class Customers extends React.Component<{}, CustomersState> {
  constructor(props: any) {
    super(props)
    this.state = { items: [] }
  }

  componentDidMount() {
    context
        .model('People')
        .asQueryable()
        .getItems()
        .then((items) => {
          this.setState({
            items
          })
        })
  }

  render() {
    return (
      <>
        ...
      </>
    )
  }
}

License

BSD-3-Clause © THEMOST LP

2.13.0

3 months ago

2.11.0

6 months ago

2.10.0

6 months ago

2.9.2

8 months ago

2.0.0

1 year ago

1.0.0

3 years ago