MCPcopy
hub / github.com/midudev/preguntas-entrevista-react / handleSetRead

Function handleSetRead

app/components/ButtonRead.jsx:35–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 })
34
35 const handleSetRead = title => {
36 if (title) {
37 const read = JSON.parse(window.localStorage.getItem('read')) || []
38 const isFavorite = read.includes(title)
39 if (isFavorite) {
40 read.splice(read.indexOf(title), 1)
41 setIsRead(false)
42 } else {
43 read.push(title)
44 setIsRead(true)
45 }
46
47 const newValue = JSON.stringify(read)
48 window.localStorage.setItem('read', newValue)
49 window.dispatchEvent(
50 new CustomEvent('local-storage', {
51 detail: { key: 'read', newValue },
52 })
53 )
54 }
55 }
56
57 return (
58 <button

Callers 1

ButtonReadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected