Comments (6)
This is pretty clearly a GPT-generated submission, not "novel" (lots of prior art), and not something that ought to be included in the React core. Not only that, but React works in environments where IndexedDB doesn't even exist.
from react.
This is pretty clearly a GPT-generated submission, not "novel" (lots of prior art), and not something that ought to be included in the React core. Not only that, but React works in environments where IndexedDB doesn't even exist.
Hi
My native language is not English, and in order to make the request look professional, I asked Chatgpt for help in writing the request text, and this is not a bad thing at all.
from react.
@Mahdi-Hazrati yeah totally understandable. One thing that might be helpful would be to mention that when you submit an issue just as a heads up. As maintainers, we are starting to get a ton of chatgpt/ai generated issues and it's hard to know which issues are generated vs assisted by AI.
For the proposal itself, a custom hook like you wrote is the perfect use case for custom hooks. It doesn't make sense to add something like this to React itself when a) it's possible to write it in user land, and b) not every environment can use IndexedDB as @markerikson mentioned.
For something like this to work in a generic way, React would want to have a hook for storing state, with an initial value from storage like IndexedDB, and a way to sync the updates back to IndexedDB. Then, users could build their own hooks specific to where the state is saved and how it's sync'd - but React already has those hooks: useState
and useEffect
.
from react.
Hi Mahdi! Nice concept and a good suggestion. I'd like to give you my feedback.
- This feels like it should be a separate package and not a core React functionality.
- There are solutions out there that implement a similar solution, like https://github.com/donavon/use-persisted-state this package
- Randomizing the key is bad and could cause a collision. In this instance, it is easily avoidable. I'd probably change it so that the key is an argument instead of a randomized string.
- Using indexdb and not local storage is an interesting choice. Wonder how it performs against local storage.
- I think it might be more interesting if this hook exposed indexedDb in some way... Like rename this to usePersistedDatabase hook and return the . Then you could use the querying abilities of the database itself for more complex stuff. You could even combine it with https://jsstore.net/docs/get-started and query things with that syntax
Connection.select({
From: "YourTableName"
Where: {
Column1: 'value1',
Column2: 'value2'
},
OnSuccess:function (results){
console.log(results);
},
OnError:function (error) {
console.log(error);
}
});
Warn regards,
Bilgehan
from react.
Agree with @markerikson
from react.
Hello @rickhanlonii ,Thanks for the detailed explanation About this issue. This was an idea and a suggestion about a problem in state management in react application programming. State value is in page reloaded or route changes, lost
In my programming workflow I some times want my state value keep in stay,
As react maitain team Please find a solution for this problem
suggest from @blghns to convert this hook to separate npm package is good idea, I refactor my code and convert to usable hook in [Browser] application;)
from react.
Related Issues (20)
- [DevTools Bug] getCommitTree(): Invalid commit "1" for root "445". There are only "1" commits.
- [eslint-plugin-react-hooks] Missing type declarations HOT 2
- [React 19]
- Bug: useEffect is triggered even if the array as dependency variable wasn't changed. HOT 4
- [DevTools Bug]: React Devtools not working neither on vite or cra project HOT 5
- ..
- Bug: Error Recovery Mechanism Overwriting Initial Rendering Errors in Concurrent Mode HOT 1
- Bug: Empty `style={}` object values cause hydration warnings in React 18.3.1 - Includes solution
- [React 19] Cannot assign to readonly property HOT 8
- Unexpected Initial State Jump in 'useEffect" with 'setTimeout' and State Dependencies HOT 3
- React[19] Module '"react"' has no exported member 'useActionState'. HOT 2
- Bug: effect runs with stale state values outside of Concurrent React HOT 1
- Feature Request: ESLint hooks rule for accessing previous state when deriving new state
- Bug: Weird Behavior of useCallback() hook When Variables or States Are defined before and after the Callback (ES5) HOT 5
- Bug: div: `ref` is not a prop HOT 2
- Bug: useFormStatus pending state is reset when component state is updated HOT 3
- [React 19] TEST HOT 1
- `FALLBACK_THROTTLE_MS` slows tests down significantly - could it be configurable? HOT 4
- Unexpected state behavior when updating nested state objects HOT 3
- Make pre-release version naming align with semver 2 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.