Go to file
Evgeny Kuzyakov 9f8acccced
Merge pull request #116 from NearSocial/release-2.4.0
## 2.4.0

- Introduce `useState` and `useEffect`. They should work similarly to the React hooks. Example:
```jsx
const [a, setA] = useState(() => {
  console.log("Init 'a'");
  return "Y";
});

const [b, setB] = useState("B");
const [sum, setSum] = useState(0);

useEffect(() => {
  setSum(a.length + b.length);
  return () => {
    console.log("cleanup");
  };
}, [a, b]);

return (
  <div>
    A = {a}
    <br />B = {b}
    <br />
    Length sum = {sum}
    <div>
      <button onClick={() => setA((s) => s + "O")}>A</button>
      <button onClick={() => setB(b + "O")}>B</button>
    </div>
  </div>
);
```

- Add `cacheOptions` optional argument to the following methods:
  - `Social.get(keys, blockId|finality, options, cacheOptions)`
  - `Social.getr(keys, blockId|finality, options, cacheOptions)`
  - `Social.keys(keys, blockId|finality, options, cacheOptions)`
  - `Social.index(action, key, options, cacheOptions)`
  - `Near.view(contractName, methodName, args, blockId|finality, subscribe, cacheOptions)`
  - `Near.block(blockId|finality, subscribe, cacheOptions)`
    The `cacheOptions` object is optional and may contain the following property:
  - `ignoreCache` - boolean, if true, the method will ignore the cached value in the local DB and fetch the data from the API server. This will only happen once per session. Default is false.

This is useful to avoid loading stale objects that are likely to change often. For example, the index of posts for the main feed, or notifications.
```jsx
const index = Social.index(
  "post",
  "main",
  {
    limit: 10,
    order: "desc",
  },
  {
    ignoreCache: true,
  }
);
```
- Replace `lodash` dependency with `lodash.clonedeep` to reduce bundle size.
2023-09-13 12:46:05 -07:00
.github/workflows Cleanup 2023-05-30 14:05:20 +02:00
config Move VM to root 2023-02-16 09:59:08 -08:00
dist Merge branch 'dev' of github.com:NearSocial/VM into dev 2023-09-13 12:36:47 -07:00
src Merge branch 'dev' of github.com:NearSocial/VM into dev 2023-09-13 12:36:47 -07:00
.babelrc Move VM to root 2023-02-16 09:59:08 -08:00
.gitignore Add babel-loader and dist 2023-02-16 10:26:22 -08:00
CHANGELOG.md Release 2.4.0 2023-09-13 12:39:37 -07:00
LICENSE Initial template based on wiki 2022-08-23 16:21:20 -07:00
package.json Release 2.4.0 2023-09-13 12:39:37 -07:00
webpack.config.js Move VM to root 2023-02-16 09:59:08 -08:00
yarn.lock Revert "Introduce cacheOptions" 2023-09-11 10:03:05 -07:00