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 { Suspense, useState, useEffect } from 'react'; | |
function toResource(promise) { | |
let status = "pending"; | |
let result; | |
let suspender = promise.then( | |
(r) => { | |
status = "success"; | |
result = r; | |
}, |
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
module.exports = { foo: 'bar' }; |
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
var fs = require("fs"); | |
var path = require("path"); | |
const replaceImports = (pathToDir, replace) => | |
fs.readdir(pathToDir, function(err, files) { | |
if (err) { | |
console.error("Could not list the directory.", err); | |
process.exit(1); | |
} |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 1 in line 1.
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
Svelte;Other SPA libraries (React, Vue.js, Angular, etc.); | |
1. Open a website 2. Render the page using pure JS;1. Open a website 2. Wait until the code for building a virtual DOM is loaded 3. Render the page using the library; |
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
const React = require("react"); | |
const config = require("../config"); | |
const createGoogleOptimizeSnippet = experimentsIds => ` | |
gtag('config', '${config.GTM_ID}', {'optimize_id': '${ | |
config.GOOGLE_OPTIMIZE_ID | |
}'}); | |
${experimentsIds.map(expId => `gtag('set', {'expId': '${expId}'});`)} | |
window.onload = function(){dataLayer.push({'event': 'optimize.activate'});}; | |
`; |
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
class DTO: | |
def __init__(self, id_): | |
self._id = id_ | |
@property | |
def id(self): | |
return self._id | |
class UserDTO(DTO): |
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
const TodoFactory = ({ todo, onClick }) => ( | |
<li className="todo" onClick={onClick}> | |
{todo.title} | |
</li> | |
); | |
export default ({ todos }) => ( | |
<ul>{todos.map(todo => TodoFactory({ todo, onClick: console.log }))}</ul> | |
); |
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
// You have this 4 components | |
const elements = [ | |
{ type: "div", key: 0, textContent: "Container #0" }, | |
{ type: "div", key: 1, textContent: "Container #1" }, | |
{ type: "div", key: 2, textContent: "Container #2" }, | |
{ type: "div", key: 3, textContent: "Container #3" } | |
]; | |
// Delete Container #1 | |
const elements = [ |
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
const TODO_LIST_OPTIONS = { | |
wrap: false, | |
maximizeOnFoucs: true | |
}; | |
export default class extends React.PureComponent { | |
render() { | |
return <TodoList options={TODO_LIST_OPTIONS} />; | |
} | |
} |
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 default class extends React.PureComponent { | |
render() { | |
return ( | |
<TodoList | |
options={{ | |
wrap: false, | |
maximizeOnFoucs: true | |
}} | |
/> | |
); |
NewerOlder