Merge pull request #100 from NearSocial/loading-placeholder

Add `loading` prop to a Widget. It would display the passed value instead of the default loading spinner. It can be used to display a custom loading indicator or a placeholder. Example:
```jsx
<Widget
  loading={<div style={{width: "100%", height: "200px"}}>Loading...</div>}
  src="mob.near/widget/ProfilePage"
/>
This commit is contained in:
Evgeny Kuzyakov 2023-08-18 11:22:02 -07:00 committed by GitHub
commit 063a1cf3ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -30,6 +30,13 @@ const opGoerliProvider = new ethers.providers.JsonRpcProvider(
console.log(opGoerliProvider);
```
- BREAKING: Update `Ethers.send` to ignore cache and return a promise instead of the cached value.
- Add `loading` prop to a Widget. It would display the passed value instead of the default loading spinner. It can be used to display a custom loading indicator or a placeholder. Example:
```jsx
<Widget
loading={<div style={{width: "100%", height: "200px"}}>Loading...</div>}
src="mob.near/widget/ProfilePage"
/>
```
## 2.2.4

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,7 @@ const computeSrcOrCode = (src, code, configs) => {
export const Widget = React.forwardRef((props, forwardedRef) => {
const {
loading,
src: propsSrc,
code: propsCode,
depth,
@ -71,7 +72,9 @@ export const Widget = React.forwardRef((props, forwardedRef) => {
const [srcOrCode, setSrcOrCode] = useState(null);
const ethersProviderContext = useContext(EthersProviderContext);
const networkId = configs && configs.findLast(config => config && config.networkId)?.networkId;
const networkId =
configs &&
configs.findLast((config) => config && config.networkId)?.networkId;
const cache = useCache(networkId);
const near = useNear(networkId);
const accountId = useAccountId(networkId);
@ -285,6 +288,6 @@ export const Widget = React.forwardRef((props, forwardedRef) => {
</>
</ErrorBoundary>
) : (
Loading
loading ?? Loading
);
});
});