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
<h1>Example Title</h1> | |
<h2>Example SubTitle</h2> | |
<nav> | |
<a href="#normal">This is a menu link</a><br/> | |
<a href="#normal">This is a menu link</a><br/> | |
</nav> | |
<div id="content"> |
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
window.onload = function() { | |
var skipLinks = document.createElement("div"); | |
skipLinks.innerHTML += | |
'<a class="skip-main" href="#a11y_statment">Skip to Accessibility Statement</a>'; | |
skipLinks.innerHTML += | |
'<a class="skip-main" href="#content">Skip to Main Content</a>'; | |
skipLinks.innerHTML += '<a class="skip-main" href="#footer">Skip to Footer</a>'; | |
document.body.insertBefore(skipLinks, document.body.firstChild); | |
}; |
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 useForm from 'react-hook-form'; | |
export default function App() { | |
const { register, handleSubmit, errors } = useForm(); | |
const onSubmit = data => console.log(data); | |
console.log(errors); | |
return ( | |
<form onSubmit={handleSubmit(onSubmit)}> |
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 useForm from 'react-hook-form' | |
export default function App() { | |
const { register, handleSubmit, watch, errors } = useForm() | |
const onSubmit = data => { console.log(data) } | |
console.log(watch('example')) // watch input value by passing the name of it | |
return ( |
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 useForm from 'react-hook-form' | |
export default function App() { | |
const { register, handleSubmit } = useForm() | |
const onSubmit = data => console.log(data) | |
return ( | |
<form onSubmit={handleSubmit(onSubmit)}> | |
<input name="firstName" ref={register({ required: true, maxlength: 20 })} /> |
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 useForm from 'react-hook-form' | |
export default function App() { | |
const { register, errors } = useForm() | |
return ( | |
<form onSubmit={handleSubmit(onSubmit)}> | |
<Input name="firstName" ref={register({ required: true })} /> | |
{errors.firstName && 'First name is required'} |
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
// Current prelude for using `wasm_bindgen`, and this'll get smaller over time! | |
#![feature(proc_macro, wasm_custom_section, wasm_import_module)] | |
extern crate wasm_bindgen; | |
use wasm_bindgen::prelude::*; | |
// Here we're importing the `alert` function from the browser, using | |
// `#[wasm_bindgen]` to generate correct wrappers. | |
#[wasm_bindgen] | |
extern { | |
fn alert(s: &str); |
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 { greet } = wasm_bindgen; | |
function runApp() { | |
greet('World'); | |
} | |
// Load and instantiate the wasm file, and we specify the source of the wasm | |
// file here. Once the returned promise is resolved we're ready to go and | |
// use our imports. | |
wasm_bindgen('../out/main_bg.wasm').then(runApp).catch(console.error); |
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
fn main() { | |
let _height: u8 = 8; | |
let _height128: u128 = 1024; | |
let _float32: f32 = 3.45; | |
let _thisisfalse: bool = false; | |
let _char: char = '@'; | |
} |
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
fn main() { | |
let 42isImmutable = 42; | |
let mut thisNumberCanBeChanged = 10; | |
42isImmutable = 84; // ERROR: 42isImmutable is not mutable | |
thisNumberCanBeChanged = 50; | |
} |