Coder Social home page Coder Social logo

Comments (6)

markerikson avatar markerikson commented on April 25, 2024 4

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.

Mahdi-Hazrati avatar Mahdi-Hazrati commented on April 25, 2024 4

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.

rickhanlonii avatar rickhanlonii commented on April 25, 2024 4

@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.

blghns avatar blghns commented on April 25, 2024 2

Hi Mahdi! Nice concept and a good suggestion. I'd like to give you my feedback.

  1. This feels like it should be a separate package and not a core React functionality.
  2. There are solutions out there that implement a similar solution, like https://github.com/donavon/use-persisted-state this package
  3. 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.
  4. Using indexdb and not local storage is an interesting choice. Wonder how it performs against local storage.
  5. 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.

rickhanlonii avatar rickhanlonii commented on April 25, 2024 2

Agree with @markerikson

from react.

Mahdi-Hazrati avatar Mahdi-Hazrati commented on April 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.