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, { useState } from "react"; | |
| const User = ({ user }) => { | |
| if (user.disabled) { | |
| return <div>{`${user.name} is not active`}</div>; | |
| } else { | |
| const [showDetails, setShowDetails] = useState(true); | |
| const toggleShowDetails = () => setShowDetails(!showDetails); |
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, { useState, useEffect, Fragment } from "react"; | |
| const Images = images => { | |
| const imageLinks = images.map(({ link }) => link); | |
| const [imageClickCount, setImageClickCount] = useState({}); | |
| const buildImageClickCount = () => { | |
| const obj = {}; | |
| images.forEach(({ link }) => { |
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, { useState, useEffect, Fragment } from "react"; | |
| const Images = images => { | |
| if (images === undefined) return <div>Loading</div>; | |
| const imageLinks = images.map(({ link }) => link); | |
| const [imageClickCount, setImageClickCount] = useState({}); | |
| const buildImageClickCount = () => { |
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, Fragment } from "react"; | |
| const Images = images => { | |
| if (images.length === 0) return <div>Loading</div>; | |
| const imageLinks = images.map(({ link }) => link); | |
| const [imageClickCount, setImageClickCount] = useState({}); | |
| useEffect(() => { |
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 PropTypes from "prop-types"; | |
| import React, { useContext, createContext, useReducer } from "react"; | |
| import { omitObjectKey } from "../../lib/object"; | |
| const EMPTY_OBJECT = {}; | |
| const TypersStateContext = createContext(); | |
| const TypersDispatchContext = createContext(); |
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, { useState } from "react"; | |
| // users prop is an array of 500k users..each user may have at least one of name, age or country | |
| const User = ({ users }) => { | |
| const [selectedCountry, setSelectedCountry] = useState("usa"); | |
| const onSelectCountry = event => { | |
| setSelectedCountry(event.target.value); | |
| }; |
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, { useState, useEffect, Fragment } from "react"; | |
| const Images = images => { | |
| const imageLinks = images.map(({ link }) => link); | |
| const [imageClickCount, setImageClickCount] = useState({}); | |
| const buildImageClickCount = () => { | |
| const obj = {}; | |
| images.forEach(({ link }) => { |
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, { useState } from "react"; | |
| const User = ({ user }) => { | |
| if (user.disabled) { | |
| return <div>{`${user.name} is not active`}</div>; | |
| } else { | |
| const [showDetails, setShowDetails] = useState(true); | |
| const toggleShowDetails = () => setShowDetails(!showDetails); |
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
| # TIME ALLOWED: 15mins | |
| class User < ApplicationRecord | |
| has_many :customers | |
| end | |
| class Customer < ApplicationRecord | |
| belongs_to :user | |
| has_many :transactions | |
| end |
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
| <!-- TIME ALLOWED: 5mins --> | |
| 1. What is the difference between `Time.now` and `Time.current` |
NewerOlder