Package Exports
- use-upbit-api
- use-upbit-api/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (use-upbit-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
use-upbit-api v1.0.0
The use-upbit-api custom hook for Upbit API (Korea crypto exchange). In the previous, Upbit API's Websocket usage in React is difficult for developer who is unfamiliar with websocket in React, but this React Custom Hook solve the problem. Let's use this awesome custom hooks!
- Always opening to join this project for developing this library.
- Typescript is supported.
View Demo here
Git Repository here
Install
npm install --save use-upbit-api
Usage
Git Example is here
useFetchMarketCode
import { useFetchMarketCode } from "use-upbit-api";
function App() {
const { isLoading, marketCodes } = useFetchMarketCode();
return (
<>
{!isLoading ? marketCodes.map((ele) =>
<div key={ele.market}>
{ele.market}
</div>)
: null
}
</>
);
}
export default App;
useUpbitWebSocket
ticker API
import { useFetchMarketCode } from "use-upbit-api";
import { useUpbitWebSocket } from "use-upbit-api";
function App() {
const option = { throttle_time: 400, max_length_queue: 100 };
const { isLoading, marketCodes: targetMarketCodes } = useFetchMarketCode();
const { socket, isConnected, socketData } = useUpbitWebSocket(targetMarketCodes, "ticker", option);
return (
<>
<table>
<thead>
<tr>
<th>코인</th>
<th>현재가</th>
<th>등락률</th>
</tr>
</thead>
<tbody>
{socketData
? socketData.map((data, index) => (
<tr key={`${data.code}_${index}`}>
<td>{data.code}</td>
<td>{data.trade_price}</td>
<td>{(data.signed_change_rate * 100).toFixed(2)}%</td>
</tr>
))
: null}
</tbody>
</table>
</>
);
}
export default App;