Skip to content

Conversation

@JasminePRA
Copy link
Collaborator

Pull Request

Description

  • Provides three methods: getItem, setItem, and removeItem
  • Handles JSON parsing/stringifying automatically
  • Returns null for non-existent keys instead of throwing errors
import useLocalStorage from './hooks/useLocalStorage';

const MyComponent = () => {
  const { getItem, setItem, removeItem } = useLocalStorage();
  
  // Store complex objects
  setItem('user', { name: 'John', age: 30 });
  
  // Retrieve and auto-parse
  const user = getItem('user'); // Returns parsed object or null
  
  // Clean up
  removeItem('user');
};

Type of Change

  • feature: New feature
  • chore: Maintenance, dependency updates, or refactoring
  • test: Adding or improving tests
  • bug: Bug fix
  • docs: Documentation updates
  • Other (please specify):

Shortcut story

https://trello.com/c/KsoEtS2D/20-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants