https://github.com/ninest/rh
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ninest/rh
- Owner: ninest
- Created: 2023-02-06T03:14:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-17T05:35:13.000Z (over 3 years ago)
- Last Synced: 2025-02-25T02:17:15.305Z (over 1 year ago)
- Language: TypeScript
- Size: 133 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Development
### `useParameters` and `useSecurities`
The `onDay` function in `useSecurities` requires `useParameters`'s `parameters` to get the next value of a stock/crypto. But getting the parameters with `const { parameters } = useParameters()` and passing and using it is not enough.
It seems that `onDay` is passed and called in `startTimer` in `useGame`, only the initial value of parameters is "caught". To fix, this, there needs to be a function that gets the current value of parameters:
```tsx
let parameters: Parameters;
setParameters((p) => {
parameters = p;
return p;
});
// parameters is now the updated value
```
This is hacky, but it works.
This might be because `useSecurities` itself does not call `onDay`, but rather it is called inside an interval.