@themost/react
v2.13.0
Published
MOST Web Framework React Client
Downloads
4
Readme
@themost/react
@themost-framework client library for react based on @themost/client
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