-
Notifications
You must be signed in to change notification settings - Fork 178
11. (NEW) React SDK
From version 2.1.0-rc.14 the LoopBack SDK Builder now supports React JS. The current implementation is not yet as mature as the Angular 2+ one, but currently provides the following features:
- Generate SDKs for React Apps
- Models and Services
$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -l react -i disabled -t false
Just note that for now you need to disable real-time features -i (io module Real Time Communication)
and typingsas well -t (Typed SDK)
is false, for now io and typings are not available for react.
Following the High-Order Components (HOC) Pattern, you will require to extend the Component
class available in your generated SDK, it will provide to you any service or model but also React functionality.
Finally you can inject the generated services by calling super() as follows:
import React from 'react';
import SDK, { Component } from './shared/sdk/';
class App extends Component {
constructor() {
super({services: ['RoomApi']});
}
componentDidMount() {
this.RoomApi.find().subscribe(data => {
console.log(data);
})
}
render() {...}
}
export default App;
The React SDK is currently under development, more features and documentation will be added in a near future.