Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Nov 29, 2021
1 parent 0b2d92c commit fdfe357
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/exercise/02.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from 'react'

function Greeting({initialName = ''}) {
// 🐨 initialize the state to the value from localStorage
// 💰 window.localStorage.getItem('name') || initialName
// 💰 window.localStorage.getItem('name') ?? initialName
const [name, setName] = React.useState(initialName)

// 🐨 Here's where you'll use `React.useEffect`.
Expand Down
2 changes: 1 addition & 1 deletion src/final/02.extra-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react'

function Greeting({initialName = ''}) {
const [name, setName] = React.useState(
() => window.localStorage.getItem('name') || initialName,
() => window.localStorage.getItem('name') ?? initialName,
)

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/final/02.extra-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react'

function Greeting({initialName = ''}) {
const [name, setName] = React.useState(
() => window.localStorage.getItem('name') || initialName,
() => window.localStorage.getItem('name') ?? initialName,
)

React.useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/final/02.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from 'react'

function Greeting({initialName = ''}) {
const [name, setName] = React.useState(
window.localStorage.getItem('name') || initialName,
window.localStorage.getItem('name') ?? initialName,
)

React.useEffect(() => {
Expand Down

0 comments on commit fdfe357

Please sign in to comment.