Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@rescriptbr/react-query
Advanced tools
Installation // Getting Started // <a target="_blank" href="#supported-feature
Installation //
Getting Started //
Supported Features //
ReScript Brazil Community
:warning: This repo contains experimental bindings for @tanstack/query using the experimental optional fields API with ReScript@v10. If you're looking bindings to the React Query v3 click here.
Install the package using npm/yarn:
yarn add @rescriptbr/react-query react-query
Add the package to bs-dependencies
in your bsconfig.json
:
{
"bs-dependencies": [
"@rescript/react",
"@rescriptbr/react-query"
]
}
/*
* Local bindings for fetch
*/
module Fetch = {
type response
@send external json: response => Js.Promise.t<'a> = "json"
@val external fetch: string => Js.Promise.t<response> = "fetch"
}
type todo = {id: string, title: string}
let apiUrl = "https://jsonplaceholder.typicode.com/todos/1"
let fetchTodos = (_): Js.Promise.t<todo> => {
Fetch.fetch(apiUrl)->Promise.then(Fetch.json)
}
module TodoItem = {
@react.component
let make = () => {
let queryResult = ReactQuery.useQuery(
ReactQuery.queryOptions(
~queryFn=fetchTodos,
~queryKey="todos",
/*
* Helper functions to convert unsupported TypeScript types in ReScript
* Check out the module ReactQuery_Utils.res
*/
~refetchOnWindowFocus=ReactQuery.refetchOnWindowFocus(#bool(false)),
(),
),
)
<div>
{switch queryResult {
| {isLoading: true} => "Loading..."->React.string
| {data: Some(todo), isLoading: false, isError: false} =>
`Todo Title ${todo.title}`->React.string
| _ => `Unexpected error...`->React.string
}}
</div>
}
}
/*
* Create a new client
*/
let client = ReactQuery.Provider.createClient()
@react.component
let make = () => {
<ReactQuery.Provider client>
<div> <h1> {React.string("ReScript + React Query")} </h1> <TodoItem /> </div>
</ReactQuery.Provider>
}
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as React from "react";
import * as ReactQuery from "@rescriptbr/react-query/src/ReactQuery.bs.js";
import * as ReactQuery$1 from "react-query";
var Fetch = {};
var apiUrl = "https://jsonplaceholder.typicode.com/todos/1";
function fetchTodos(param) {
return fetch(apiUrl).then(function (prim) {
return prim.json();
});
}
function App$TodoItem(Props) {
var queryResult = ReactQuery$1.useQuery({
queryKey: "todos",
queryFn: fetchTodos,
refetchOnWindowFocus: ReactQuery.refetchOnWindowFocus({
NAME: "bool",
VAL: false,
}),
});
var tmp;
if (queryResult.isLoading) {
tmp = "Loading...";
} else if (queryResult.isError) {
tmp = "Unexpected error...";
} else {
var todo = queryResult.data;
tmp =
todo !== undefined ? "Todo Title " + todo.title : "Unexpected error...";
}
return React.createElement("div", undefined, tmp);
}
var TodoItem = {
make: App$TodoItem,
};
var client = new ReactQuery$1.QueryClient();
function App(Props) {
return React.createElement(ReactQuery$1.QueryClientProvider, {
client: client,
children: React.createElement(
"div",
undefined,
React.createElement("h1", undefined, "ReScript + React Query"),
React.createElement(App$TodoItem, {})
),
});
}
These bindings are work in progress, check out the supported features:
=
Fully implemented=
Not implemented yet=
Work in progress=
Partially implementedMIT
FAQs
Installation // Getting Started // <a target="_blank" href="#supported-feature
We found that @rescriptbr/react-query demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.