Skip to content

Instantly share code, notes, and snippets.

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);
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 }) => {
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 = () => {
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(() => {
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();
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);
};
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 }) => {
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);
# TIME ALLOWED: 15mins
class User < ApplicationRecord
has_many :customers
end
class Customer < ApplicationRecord
belongs_to :user
has_many :transactions
end
<!-- TIME ALLOWED: 5mins -->
1. What is the difference between `Time.now` and `Time.current`