1.3.0 • Published 1 year ago

pnp-react-hooks v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

PnP React Hooks

PnP React Hooks is a wrapper library for PnPjs, provides configurable React hooks for SharePoint Rest API.

Usage:

import * as React from "react";
import { useListItems, useCurrentUser } from "pnp-react-hooks";

export const ExampleComponent = () => {

	const currentUser = useCurrentUser();

	const items = useListItems("My List", {
		query: {
			select: ["Title", "Id", "Author/Title"],
			expand: ["Author"],
			filter: `Author eq ${currentUser?.Id}`
		},
		disabled: !currentUser
	});

	return (<ul> { items?.map(item => (<li key={item.Id}>{item.Title}</li>)) } </ul>);
};

Installation

Npm v7+

npm install pnp-react-hooks

Npm v3-6

You have to install peer dependencies manually when using older npm versions.

npm install pnp-react-hooks @pnp/sp react

Documentation

For more details see the docs site.

Disclaimer

PnP React Hooks library is an open source project under MIT license. It's NOT an official package distributed by Microsoft.

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago