yarn add is-even-indreklasn
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 { | |
webkit, | |
firefox, | |
chromium | |
} = require('playwright'); | |
const simulateBrowser = async (browserEngine) => { | |
const browser = await browserEngine.launch({ headless: false, slowMo: 50 }); | |
const page = await browser.newPage(); |
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 { createAction } from '@reduxjs/toolkit' | |
const addTodo = createAction('ADD_TODO') | |
export default addTodo; | |
// Usage | |
addTodo({ text: 'Buy milk' }) |
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 { createReducer } from '@reduxjs/toolkit' | |
const todosReducer = createReducer([], { | |
ADD_TODO: (state, action) => { | |
// "mutate" the array by calling push() | |
state.push(action.payload) | |
}, | |
TOGGLE_TODO: (state, action) => { | |
const todo = state[action.payload.index] | |
// "mutate" the object by overwriting a field |
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 { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit' | |
import monitorReducersEnhancer from './enhancers/monitorReducers' | |
import loggerMiddleware from './middleware/logger' | |
import rootReducer from './reducers' | |
export default function configureAppStore(preloadedState) { | |
const store = configureStore({ | |
reducer: rootReducer, | |
middleware: [loggerMiddleware, ...getDefaultMiddleware()], |
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 { configureStore } from '@reduxjs/toolkit' | |
import rootReducer from './reducers' | |
const store = configureStore({ | |
reducer: rootReducer | |
}) | |
export default store |
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 { applyMiddleware, createStore } from 'redux' | |
import { composeWithDevTools } from 'redux-devtools-extension' | |
import thunkMiddleware from 'redux-thunk' | |
import monitorReducersEnhancer from './enhancers/monitorReducers' | |
import loggerMiddleware from './middleware/logger' | |
import rootReducer from './reducers' | |
export default function configureStore(preloadedState) { | |
const middlewares = [loggerMiddleware, thunkMiddleware] |
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
{ | |
"name": "is-even-[your-name-here]", | |
"version": "1.0.1", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [ | |
"example", |
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 isEven = (number) => { | |
return number % 2 === 0 | |
} | |
module.exports = isEven |
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
type MyProps = { | |
// using `interface` is also ok | |
message: string; | |
}; | |
type MyState = { | |
count: number; // like this | |
}; | |
class App extends React.Component<MyProps, MyState> { | |
state: MyState = { | |
// optional second annotation for better type inference |