@soubai/use-wikipedia
v1.0.4
Published
A simple react hook for query wikipedia API
Downloads
3
Maintainers
Readme
🧰 useWikipedia: React Hook for query wikipedia API
A hook to help you to query a wikipedia search API
install
yarn add @soubai/use-wikipedia
Usage
import useWikipedia from "@soubai/use-wikipedia";
function MyComponent() {
const { data, error } = useDocumentTitle("Morocco");
return <div />;
}
- OR
import useWikipedia from "@soubai/use-wikipedia";
const [error, setError] = useState(null);
const [data, setData] = useState([]);
const [q, setQ] = useState("");
const { query } = useWikipedia();
const search = async () => {
// query take search string and limit result per page (default 10)
const { data, error } = await query(q, 10);
setData(data);
setError(error);
};
Example
for more detail about use see ./example/