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
export const debounce = (fn, wait, immediate) => { | |
let timeout | |
return (...args) => { | |
const context = this | |
const later = () => { | |
timeout = null | |
if (!immediate) fn.apply(context, args) |
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
function App() { | |
return ( | |
<div className="container-fluid"> | |
<div className="row"> | |
<div className="col-lg-6 col-md-6"> | |
<FormDebounce /> | |
</div> | |
<div className="col-lg-6 col-md-6"> | |
<FormControlled /> | |
</div> |
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
import React from 'react'; | |
import FormControlled from './Components/FormControlled' | |
function App() { | |
return ( | |
<div className="container-fluid"> | |
<div className="row"> | |
<div className="col-lg-6 col-md-6"> | |
{/* vai receber segundo abordagem */} | |
</div> |
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
import { render } from "@testing-library/react" | |
import userEvent from '@testing-library/user-event' | |
import configureMockStore from 'redux-mock-store' | |
import React from "react" | |
import { asyncActionMiddleware } from "redux-infinity-state" | |
import { Provider } from "react-redux" | |
import { actions, Todo } from "../../store/states/todos" | |
import TodoList from "." |
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
import React from "react"; | |
import { useSelector, useDispatch } from "react-redux"; | |
import { AppState } from "../../store"; | |
import { actions, Todo } from "../../store/states/todos"; | |
const TodoList = () => { | |
const todos = useSelector<AppState, Array<Todo>>(state => state.todos); | |
const dispatch = useDispatch(); |
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
import { render, fireEvent } from "@testing-library/react" | |
import userEvent from '@testing-library/user-event' | |
import configureMockStore from 'redux-mock-store' | |
import TodoForm from "." | |
import React from "react" | |
import { asyncActionMiddleware } from "redux-infinity-state" | |
import { Provider } from "react-redux" | |
import { appState } from "../../store" | |
import { actions } from "../../store/states/todos" |
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
import React, { useState, FormEvent } from "react"; | |
import { useDispatch } from "react-redux"; | |
import { actions } from "../../store/states/todos"; | |
const TodoForm = () => { | |
const [inputText, setInputText] = useState(''); | |
const dispatch = useDispatch(); | |
const handleSubmit = (e: FormEvent<HTMLFormElement>) => { |
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
import { INITIAL_STATE, actions, reducer } from "." | |
import Axios from "axios" | |
import { asyncActionMiddleware } from "redux-infinity-state/build/main/lib/asyncActionMiddleware" | |
import configureMockStore, { MockStore } from 'redux-mock-store' | |
import { AnyAction } from "redux" | |
describe("Test Methods Todos Context", () => { | |
const todoText = "Todo Test" | |
it("Test AddTodo", () => { |
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
import React from "react"; | |
import { Provider } from "react-redux"; | |
import store from "./store"; | |
import TodoList from "./TodoList"; | |
const App = () => ( | |
<Provider store={store}> | |
<TodoList /> | |
</Provider> | |
); |
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
import "./styles.css"; | |
import React,{ useState, FormEvent } from "react"; | |
import { useSelector, useDispatch } from "react-redux"; | |
import { AppState } from "./store"; | |
import {actions} from "./store/todos/reducer"; | |
const TodoList = () => { | |
const [inputText, setInputText] = useState(''); | |
const todos = useSelector((state:AppState) => state.todos); |