This file contains hidden or 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
import React from 'react' | |
import { useDispatch, useSelector } from 'react-redux' | |
import { createSlice } from '@reduxjs/toolkit' | |
// 1) Create state and actions/reducers | |
const counterSlice = createSlice({ | |
name: 'counter', | |
initialState: { | |
value: 0, | |
}, | |
reducers: { |
This file contains hidden or 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
// App.js | |
import { QueryClient, QueryClientProvider} from 'react-query' | |
const queryClient = new QueryClient() | |
export default function App() { | |
return ( | |
<QueryClientProvider client={queryClient}> | |
<Component /> | |
</QueryClientProvider> | |
) | |
} |
This file contains hidden or 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
// Auth.js | |
const AuthContext = createContext({username: '', role: ''}); | |
export function useAuth() { | |
const context = useContext(AuthContext); | |
if (!context) { | |
throw new Error('useAuth must be used within a AuthProvider'); | |
} | |
return context; | |
} | |
export function AuthProvider({ children }) { |
This file contains hidden or 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
const initialState = {count: 0}; | |
function reducer(state, action) { | |
switch (action.type) { | |
case 'increment': | |
return {count: state.count + 1}; | |
case 'decrement': | |
return {count: state.count - 1}; | |
case 'set': | |
return {count: action.count}; | |
case 'reset': |
This file contains hidden or 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
function Counter({initialCount: 42}) { | |
const [count, setCount] = useState(initialCount); | |
return ( | |
<> | |
Count: {count} | |
<button onClick={() => setCount(initialCount)}>Reset</button> | |
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button> | |
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button> | |
</> | |
); |
This file contains hidden or 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
// 1) | |
let isOpen = false; | |
// 2) | |
let addressForm = { | |
first: "Donald", | |
last: "Duck", | |
street: "Webfoot Walk", | |
no: "1313", | |
town: "Duckburg", | |
state: "Calisto", |
This file contains hidden or 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
... | |
"electronInstallerDebian": { | |
"icon": "./icon.svg", | |
"categories": [ | |
"Utility" | |
], | |
"homepage": "https://foo.com" | |
}, | |
... |
This file contains hidden or 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
const isDevMode = process.execPath.match(/[\\/]electron[\\/]/); |
This file contains hidden or 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
"description": "Rebuild of the gtk3-demo-application with electron", | |
... | |
"linux": [ | |
"deb | |
] | |
... | |
"electronPackagerConfig": { | |
"packageManager": "yarn", | |
"executableName": "electron-react-example", | |
"icon": "./icon.svg" |
This file contains hidden or 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
... | |
{ | |
label: 'Help', role: 'help', | |
submenu: [ submenu: [ | |
{ { | |
label: 'About', label: 'About', | |
... | |
if (process.platform === 'darwin') { | |
const name = app.getName(); | |
menu.unshift({ |
NewerOlder