-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react): change InstanceTable -> InstanceList, refreshInterval
- Loading branch information
Showing
13 changed files
with
134 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Instance Table | ||
|
||
A list (defaults to a table based on [data grid table in mui](https://mui.com/x/react-data-grid/)) for rendering instances. | ||
|
||
The default exports transparently handles request and loading state. | ||
|
||
## Usage | ||
|
||
```typescript | ||
import { InstanceList, NileProvider } from '@theniledev/react'; | ||
|
||
const API_URL = 'http://localhost:8080'; // location of the Nile endpoint | ||
|
||
function App() { | ||
return ( | ||
<NileProvider basePath={API_URL}> | ||
<InstanceList entity="myEntity" org="userOrg" /> | ||
</NileProvider> | ||
); | ||
} | ||
``` | ||
|
||
## Customization | ||
|
||
See the [InstanceList storybook](https://react-storybook-ten.vercel.app/?path=/story/InstanceList--default) for samples on customizing `<InstanceList />` to fit your needs. | ||
|
||
If you need full control over rendering, you can pass a `Component` prop. `<InstanceList />` will do the data fetching, and pass props back to you. | ||
|
||
```typescript | ||
import { InstanceList, NileProvider, ComponentProps } from '@theniledev/react'; | ||
|
||
const API_URL = 'http://localhost:8080'; // location of the Nile endpoint | ||
|
||
function HandleEverything(props: ComponentProps) { | ||
return <>{JSON.stringify(props)}</>; | ||
} | ||
|
||
function App() { | ||
return ( | ||
<NileProvider basePath={API_URL}> | ||
<InstanceList | ||
entity="myEntity" | ||
org="userOrg" | ||
Component={HandleEverything} | ||
/> | ||
</NileProvider> | ||
); | ||
} | ||
``` | ||
|
||
## Theming | ||
|
||
[theming](../../../README.md#UI%20customization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { default as InstanceList } from './InstanceListDataFetcher'; | ||
|
||
export default InstanceList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
export const useInterval = (cb: () => void, delay: void | number) => { | ||
const savedCallback = React.useRef(cb); | ||
|
||
React.useEffect(() => { | ||
savedCallback.current = cb; | ||
}, [cb]); | ||
|
||
React.useEffect(() => { | ||
if (!delay) { | ||
return; | ||
} | ||
const id = setInterval(() => savedCallback.current(), delay); | ||
return () => clearInterval(id); | ||
}, [delay]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters