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
interface Props { | |
render: (count: number, setCount: React.Dispatch => JSX.Element | |
} | |
// props only render and does nothing else. | |
export const Counter: React.FC<Props> = ( { render } ) => { | |
const [count, setCount] = useState(0); | |
return ( | |
<div> |
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
// A component with render prop takes a function that returns React element and calls it instead of | |
// implementing its own render | |
// render, props is a function | |
// render prop is a funtion that takes in data, and return JSX element? | |
<DataProvider render={data => ( | |
<h1>Hello {data.target} </h1> | |
)}/> | |
// instead rendering from SharedComponent, you render using props. |
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
interface Props { | |
text: string | |
} | |
export const TextField: React.FC<Props> = () => { | |
} |
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
// takes in interface Values | |
const handleOnSubmit = (values: Values) => { | |
setIsSubmitting(true); | |
// this is the one tripping me up. | |
fetchCurrentShop(async (shop: Shop, address: Address) => { | |
} | |
<Formik | |
initialValues={initialValues} |
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
public void TryAcceptReturnsReservationIdInHappyPathScenario( | |
[Frozen]Mock<IReservationsRepository> td, | |
Reservation reservation, | |
IReadOnlyCollection<Reservation> reservations, | |
MaîtreD sut, | |
int excessCapacity, | |
int expected) | |
{ | |
// i think td refers to test-double | |
// ReservationsRepository is mocked |
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
class TextParser | |
attr_reader :text, :parser | |
def initialize(text, parser) | |
@text = text | |
@parser = parser | |
end | |
def call | |
parser.call(text) |
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
defmodule Servy.Handler do | |
def route(conv) do | |
if conv.path == '/wildthings' do | |
%{ conv | resp_body: "Bears, Lions, Tigers"} | |
else | |
%{ conv | r esp_body: "Bears"} | |
end | |
end | |
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
def Servy.Handler do | |
def handle(request) do | |
end | |
# route GET "/" | |
def route() do | |
%{conv | resp_body: "Hello welcome"} | |
end | |
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
defmodule Servy.Parser do | |
def parse(request) do | |
[request_info, params_string] = String.split(request, "\r\n\r\n") | |
[request_line | header_lines ] = String.split(request_info, "\r\n") | |
[method, path, _http_protocol ] = String.split(requestline, " ") | |
params = parse_params(headers["Content-Type"], params_string) | |
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
public static void main(String[] args) { | |
int n = StdIn.readInt() | |
QuickFindUF = new QuickFindUF(n); | |
} | |
// To merge components containing p and q, change all entries | |
// id[p] to id[q] | |
public class QuickFindUF { | |
private int[] id; | |
private int count; |