-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created jotai folder Installed react Installed jotai Uninstalled unnecessary packages Removed unnecessary folders and files Working on jotai * Added Jotai example Added Jotai to README.md file Added jalalbmnf to .all-contributorsrc file Co-authored-by: Jalal Manafi <[email protected]>
- Loading branch information
1 parent
b94d24b
commit 0e89c11
Showing
10 changed files
with
15,099 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
If you use yarn, run: | ||
`yarn && yarn start` | ||
|
||
If you use npm, run: | ||
`npm i && npm run start` |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "react-jotai", | ||
"version": "0.1.0", | ||
"author": "jalalbmnf", | ||
"description": "React State Museum - Example of Jōtai", | ||
"dependencies": { | ||
"jotai": "^1.12.1", | ||
"packlist-components": "^1.2.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-scripts": "5.0.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React State Museum - Example of Jōtai</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { AddPackingItem } from "packlist-components"; | ||
import { useAtom, useSetAtom } from "jotai"; | ||
|
||
import { initialValue, items } from "../store"; | ||
|
||
const AddItem = () => { | ||
const [item, setItem] = useAtom(initialValue); | ||
const setItemList = useSetAtom(items); | ||
|
||
const addItem = () => { | ||
setItemList((prev) => [...prev, item]); | ||
setItem(""); | ||
}; | ||
|
||
const clearlist = () => { | ||
setItemList([]); | ||
}; | ||
|
||
return ( | ||
<AddPackingItem | ||
value={item} | ||
addItem={addItem} | ||
setNewItemText={(e) => setItem(e.target.value)} | ||
clear={clearlist} | ||
/> | ||
); | ||
}; | ||
|
||
export default AddItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useAtom } from "jotai"; | ||
import { SimpleList } from "packlist-components"; | ||
|
||
import { items } from "../store"; | ||
|
||
const ListItem = () => { | ||
const [list] = useAtom(items); | ||
|
||
return <SimpleList value={list} />; | ||
}; | ||
|
||
export default ListItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/************************************************ | ||
* This example is one of many examples | ||
* -= The React State Museum =- | ||
* View other state management options and read | ||
* more in the blog post and the master repo: | ||
* | ||
* https://github.com/GantMan/ReactStateMuseum | ||
************************************************/ | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import { Provider } from "jotai"; | ||
|
||
import ListItems from "./Components/listItems"; | ||
import AddItems from "./Components/addItem"; | ||
|
||
const styles = { | ||
fontFamily: "sans-serif", | ||
textAlign: "center", | ||
}; | ||
|
||
const App = () => { | ||
return ( | ||
<div style={styles}> | ||
<h2>Welcome to Jōtai</h2> | ||
<AddItems /> | ||
<ListItems /> | ||
</div> | ||
); | ||
}; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById("root")); | ||
root.render( | ||
<React.StrictMode> | ||
<Provider> | ||
<App /> | ||
</Provider> | ||
</React.StrictMode> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { atom } from "jotai"; | ||
|
||
export const items = atom(["nachos", "burritos", "hotdog"]); | ||
export const initialValue = atom(""); |