Skip to content

Commit 91d944f

Browse files
committed
add eraserMode
1 parent ac04ed2 commit 91d944f

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

client/src/atoms.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { atom} from "recoil";
2+
3+
export const eraserState = atom({
4+
key: "eraser",
5+
default: false
6+
});

client/src/components/Eraser.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import eraserImg from "../assets/eraser.png";
2+
import { useState } from "react";
23

34
function Eraser(){
5+
const [ eraserMode, setEraserMode ] = useState(false);
46

57
function clickHandler(){
6-
8+
setEraserMode(!eraserMode);
79
}
810

911
return (

client/src/main.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import React from 'react'
22
import ReactDOM from 'react-dom/client'
33
import App from './App.jsx'
44
import './index.css'
5+
import { RecoilRoot } from "recoil"
56

6-
ReactDOM.createRoot(document.getElementById('root')).render(
7+
ReactDOM.createRoot(document.getElementById("root")).render(
78
<React.StrictMode>
8-
<App />
9-
</React.StrictMode>,
10-
)
9+
<RecoilRoot>
10+
<App />
11+
</RecoilRoot>
12+
</React.StrictMode>
13+
);

0 commit comments

Comments
 (0)