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
| // apm list --installed --bare > atom-package-list.txt | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] | |
| [email protected] |
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
| class App extends React.Component { | |
| state = { users: [] }; | |
| componentDidMount() { | |
| axios("https://randomuser.me/api/?results=10&inc=name,login&nat=us").then( | |
| response => { | |
| this.setState({ | |
| users: response.data.results | |
| }); | |
| } |
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 App = () => { | |
| const [users, setUsers] = useState([]); | |
| useEffect(() => { | |
| (async () => { | |
| try { | |
| const response = await axios( | |
| "https://randomuser.me/api/?results=10&inc=name,login&nat=us" | |
| ); | |
| setUsers(response.data.results); |
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 App = () => { | |
| const users = useRandomUsers(); | |
| return ( | |
| <div className="App"> | |
| <header className="App-header"> | |
| <ol> | |
| {users && | |
| users.map(({ name, login }) => ( | |
| <li key={login.uuid}> |
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
| jest.mock("axios"); | |
| describe("useRandomUsers", () => { | |
| it("call API and return results", async () => { | |
| axios.mockImplementation(() => Promise.resolve({ data: mockResponse })); | |
| const users = useRandomUsers(); | |
| expect(users.current).toStrictEqual(mockResponse); | |
| }); | |
| }); |
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 { renderHook, act } from "react-hooks-testing-library"; | |
| jest.mock("axios"); | |
| describe("useRandomUsers", () => { | |
| it("call API and return results", async () => { | |
| axios.mockImplementation(() => Promise.resolve({ data: mockResponse })); | |
| const { result, waitForNextUpdate } = renderHook(() => useRandomUsers()); | |
| expect(result.current).toStrictEqual([]); |
OlderNewer