kandi background

web-v1-old | Static Ecommerce site built using GatsbyJs | Ecommerce library

Download this library from

kandi X-RAY | web-v1-old Summary

web-v1-old is a JavaScript library typically used in Web Site, Ecommerce, React, Next.js, Gatsby applications. web-v1-old has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can download it from GitHub.
Static E-commerce site built using GatsbyJs

kandi-support Support

  • web-v1-old has a low active ecosystem.
  • It has 83 star(s) with 26 fork(s). There are 4 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 13 open issues and 43 have been closed. On average issues are closed in 106 days. There are 22 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of web-v1-old is current.

quality kandi Quality

  • web-v1-old has 0 bugs and 0 code smells.

securitySecurity

  • web-v1-old has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • web-v1-old code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • web-v1-old is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • web-v1-old releases are not available. You will need to build from source code and install.
  • Installation instructions, examples and code snippets are available.
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

web-v1-old Key Features

Static E-commerce site built using GatsbyJs

web-v1-old Examples and Code Snippets

  • To use
  • Setup
  • Development
  • Deployment

To use

SANITY_TOKEN=YOUR_KEY_HERE

Community Discussions

Trending Discussions on Ecommerce
  • React state object turning into "[object Object]" on refresh using sessionStorage
  • Render all products that relate to one of subcategories of one category, in category page
  • UseParams() not working and not rendering data on screen
  • Problem with create table Category and get the url correctly PHP
  • proxy server working in one case and failed in another case
  • How to send previous items in cart such that my updateCart adds new items on top of previous products in cart
  • useReducer: dispatch action, show state in other component and update state when action is dispatched
  • connect spring boot to swagger
  • Can Django select_for_update be used to acquire a read lock?
  • Google Tag Manager / Enhanced E-commerce - Purchase tag dataLayer push working only on Tag Assistance
Trending Discussions on Ecommerce

QUESTION

React state object turning into "[object Object]" on refresh using sessionStorage

Asked 2022-Mar-23 at 14:53

I'm working on a dummy fullstack ecommerce app using Postgres, Express and React whilst going through a fullstack course. This question is pretty specific to React.

On login to the app I can successfully create or retrieve a cart from the db and save it to state. It's being saved as a normal object:

Cart: {id: 2, user_id: 159, product_count: 0, price: '£0.00'}

-From Chrome Dev Tools: Extensions React Developer Tools.

I'm then using React useEffect hooks to persist this state in sessionStorage:

App.js

 useEffect(() => {
    if (sessionStorage["cart"]) {
      setCart(window.sessionStorage.getItem("cart"));
    }
  }, []);

  useEffect(() => {
    window.sessionStorage.setItem("cart", cart);
  }, [cart]);

Whenever I refresh the page or go to another route the normal object seems to be turning into the string: "[object Object]".

I know it has something to do with the way I'm saving the cart state variable into the localStorage but I'm not familiar with it enough to know exactly where this is happening or how to fix it so any help would be appreciated.

I've tried changing the assignment variables within the useEffect calls to include trying to save the item as an object, but I'm not familiar enough with sessionStorage to know what's happening behind the scenes.

ANSWER

Answered 2022-Mar-23 at 14:53

When you store the object to storage, call JSON.stringify(cart) to convert from an object to a string.

When you read the object from storage, it's const cart = JSON.parse(cartString) to convert from the string back into an object.

Like so:

  useEffect(() => {
    if (sessionStorage["cart"]) {
      setCart(JSON.parse(window.sessionStorage.getItem("cart")));
    }
  }, []);

  useEffect(() => {
    window.sessionStorage.setItem("cart", JSON.stringify(cart));
  }, [cart]);

Source https://stackoverflow.com/questions/71589271

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install web-v1-old

You can download it from GitHub.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Build your Application

Share this kandi XRay Report

Reuse Pre-built Kits with web-v1-old