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
| /** | |
| * Get user by id. | |
| * @param {number} id – Id of user | |
| * @return {User} Returns User. | |
| */ | |
| function getUserById(id) { | |
| //TO DO: implement it | |
| } |
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
| /** | |
| User definition | |
| @typedef {Object} User | |
| @property {number} id - Id of the user. | |
| @property {string} name - Name of the user. | |
| @property {string=} profession - Profession of the user. Is is optional. | |
| @property {function(string):string} setProfession - Set profession of user | |
| */ | |
| /** @type {User} */ |
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
| /** @typedef {{x:number, y:number}} Point */ | |
| /** @type {Point} */ | |
| var point; |
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 {(string|Array)} */ | |
| var address; |
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 {number} */ | |
| var price; |
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 street; | |
| if (user && user.address && user.address.street) { | |
| street = user.address.street; | |
| } |
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 street = ((user || {}).address || {}).street |
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 street = user?.street?.address |
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 { useState, useEffect } from 'react'; | |
| const useFetch = (request, payload) => { | |
| const [data, setData] = useState(null); | |
| const [loading, setLoading] = useState(true); | |
| const [error, setError] = useState(null); | |
| useEffect(() => { | |
| let isMounted = true; | |
| setError(null); |
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 Emitter from '../services/emitter'; | |
| import '../styles/Header.css'; | |
| class Header extends React.Component { | |
| state = { header: 'Default header' }; | |
| componentDidMount() { | |
| Emitter.once('INPUT_FROM_MAIN', (newValue) => this.setState({ header: newValue })); |
NewerOlder