- Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
# esto en caso de trabajar con typescript
yarn add --dev @babel/preset-typescript| import {useState} from "react" | |
| export const useForm = (initialState = {}) => { | |
| const [values,setValues] = useState(initialState) | |
| const reset = () => { | |
| setValues(initialState) | |
| } |
| declare module '*.jpg' { | |
| const content: any; // you can also set this to string | |
| export default content; | |
| } |
| import {useReducer, useState} from "react" | |
| interface CounterState { | |
| counter: number | |
| previus: number | |
| changes: number | |
| } | |
| const INITIAL_STATE:CounterState = { |
| font_family Caskaydia Cove Nerd Font | |
| font_size 12.0 | |
| background_opacity .8 | |
| remember_window_size no | |
| initial_window_width 640 | |
| initial_window_height 350 | |
| cursor_shape beam | |
| cursor_beam_thickness 1.8 |
| [redshift] | |
| temp-day=5800 | |
| temp-night=2400 | |
| transition=0 | |
| gamma=0.8 | |
| location-provider=manual | |
| [manual] | |
| lat=-33.5 | |
| lon=-70.5 | |
| [randr] |
| [user] | |
| name = kensaaa | |
| email = ke.samata.ramos@gmail.com | |
| [core] | |
| editor = nvim | |
| [alias] | |
| s = status -sb | |
| lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
| [github] | |
| user = kensaaa |
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
# esto en caso de trabajar con typescript
yarn add --dev @babel/preset-typescript| import { useCounter } from "../hooks/useCounter"; | |
| const CounterWithCustomHook = () => { | |
| const { counter, increment, decrement, reset } = useCounter(10); | |
| return ( | |
| <> | |
| <h1>Counter With Hook: {counter}</h1> | |
| <hr /> |
| import { useState } from 'react'; | |
| interface useFormReturn { | |
| formState: any; | |
| onInputChange(e: any): void; | |
| onResetForm(): void; | |
| } | |
| export const useForm = (initalForm = {}): useFormReturn => { | |
| const [formState, setFormState] = useState(initalForm); |
| import { createSlice } from '@reduxjs/toolkit'; | |
| export const templateSlice = createSlice({ | |
| name: 'name', | |
| initialState: { | |
| counter: 10 | |
| }, | |
| reducers: { | |
| increment: (state, /* action */ ) => { | |
| //! https://react-redux.js.org/tutorials/quick-start |