Skip to content

Commit 5481420

Browse files
committed
add show checkbox
1 parent f895e48 commit 5481420

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

17-dom-refs.html

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
'max-glare': 0.5,
5656
}
5757
VanillaTilt.init(tiltNode, vanillaTiltOptions)
58-
return () => tiltNode.vanillaTilt.destroy()
58+
return () => {
59+
tiltNode.vanillaTilt.destroy()
60+
}
5961
}, [])
6062

6163
return (
@@ -65,12 +67,27 @@
6567
)
6668
}
6769

68-
const element = (
69-
<Tilt>
70-
<div className="totally-centered">vanilla-tilt.js</div>
71-
</Tilt>
72-
)
70+
function App() {
71+
const [showTilt, setShowTilt] = React.useState(true)
72+
return (
73+
<div>
74+
<label>
75+
<input
76+
type="checkbox"
77+
checked={showTilt}
78+
onChange={e => setShowTilt(e.target.checked)}
79+
/>{' '}
80+
show tilt
81+
</label>
82+
{showTilt ? (
83+
<Tilt>
84+
<div className="totally-centered">vanilla-tilt.js</div>
85+
</Tilt>
86+
) : null}
87+
</div>
88+
)
89+
}
7390

74-
ReactDOM.render(element, document.getElementById('root'))
91+
ReactDOM.render(<App />, document.getElementById('root'))
7592
</script>
7693
</body>

0 commit comments

Comments
 (0)