Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1111,34 +1111,17 @@ Parameters:

Get a URL that points to a StyleJSON resource served by the embedded HTTP server.

If `opts.refreshToken` is specified, it will be appended to the returned URL as a search param. This is useful for forcing cache busting
due to hidden internal details by consuming components (e.g. map component from MapLibre).

| Function | Type |
| ---------- | ---------- |
| `useMapStyleUrl` | `() => { data: string; error: Error or null; isRefetching: boolean; }` |

Parameters:

* `opts.refreshToken`: String to append to the returned value as a search param


Examples:

```tsx
function ExampleWithoutRefreshToken() {
const { data, isRefetching } = useMapStyleUrl()

console.log(data) // logs something like 'http://localhost:...'
}
```

```tsx
function ExampleWithRefreshToken() {
const [refreshToken] = useState('foo')
const { data } = useMapStyleUrl({ refreshToken })

console.log(data) // logs something like 'http://localhost:...?refresh_token=foo'
console.log(data) // logs something like 'http://127.0.0.1:...'
}
```

Expand Down
16 changes: 1 addition & 15 deletions src/hooks/maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,12 @@ import {
/**
* Get a URL that points to a StyleJSON resource served by the embedded HTTP server.
*
* If `opts.refreshToken` is specified, it will be appended to the returned URL as a search param. This is useful for forcing cache busting
* due to hidden internal details by consuming components (e.g. map component from MapLibre).
*
* @param opts.refreshToken String to append to the returned value as a search param
*
* @example
* ```tsx
* function ExampleWithoutRefreshToken() {
* const { data, isRefetching } = useMapStyleUrl()
*
* console.log(data) // logs something like 'http://localhost:...'
* }
* ```
*
* ```tsx
* function ExampleWithRefreshToken() {
* const [refreshToken] = useState('foo')
* const { data } = useMapStyleUrl({ refreshToken })
*
* console.log(data) // logs something like 'http://localhost:...?refresh_token=foo'
* console.log(data) // logs something like 'http://127.0.0.1:...'
* }
* ```
*/
Expand Down
Loading