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 React, { Component } from 'React'; | |
import PropTypes from 'prop-types'; | |
class ClickOutside extends Component { | |
static propTypes = { | |
onClick: PropTypes.func | |
} | |
constructor(props) { | |
super(props); |
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 React, { Component } from 'React'; | |
import PropTypes from 'prop-types'; | |
class ClickOutside extends Component { | |
static propTypes = { | |
onClick: PropTypes.func | |
} | |
constructor(props) { | |
super(props); |
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 React, { Component } from 'react'; | |
class ClickOutside extends Component { | |
handleClick = e => { | |
console.log('clicking everywhere!'); | |
}; | |
componentDidMount() { | |
document.addEventListener("click", this.handleClick); | |
} |
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 React, { Component } from 'react'; | |
class ClickOutside extends Component { | |
handleClick = e => { | |
console.log('clicking everywhere!'); | |
}; | |
componentDidMount() { | |
document.addEventListener("click", this.handleClick); | |
} |
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
<ClickOutside onClick=() => 'Close tooltip'> | |
<span> | |
A helpful tooltip! | |
</span> | |
</ClickOutside> |
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 * as fuzzySearch from "fuzzy-search"; | |
import books from './books-db'; | |
import lorem from './lorem'; | |
const loremOpts = { | |
isHardcore: false | |
}; | |
renderLorem(); | |
renderBooks(books); |
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
extern crate cfg_if; | |
extern crate wasm_bindgen; | |
extern crate regex; | |
#[macro_use] | |
extern crate serde_derive; | |
use wasm_bindgen::prelude::*; | |
use regex::Regex; | |
#[wasm_bindgen] |
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
process.argv | |
.filter(function(item){ return !Number.isNaN(Number(item)); }) | |
.map(function(item){ return Number(item); }) | |
.reduce(function(acc, item){ return acc + item }, 0); |
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
fetch('memory-access.gc.wasm') | |
.then(r => r.arrayBuffer()) | |
.then(arrayBuff => WebAssembly.instantiate(arrBuff, {})) | |
.then(rustWasm => { | |
const vecLocation = wasmRust.instance.exports.simple_arr(); | |
const vecTyped = new Uint32Array(wasmRust.instance.exports.memory.buffer, vecLocation, 4); | |
const simpleVec = [...vecTyped] | |
console.log(simpleVec) | |
// [ 100, 200, 300, 400 ] |
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
$ rustc +nightly --target wasm32-unknown-unknown -O vector.rs | |
$ wasm-gc vector.wasm vector.wasm | |
$ python -m SimpleHTTPServer # Power up an inline HTTP server on port 80 |