Skip to content

Instantly share code, notes, and snippets.

View eyaleizenberg's full-sized avatar

Eyal Eizenberg eyaleizenberg

View GitHub Profile
interface IProps {
superhero: string;
}
interface IState {
health: number;
}
export class MyComponent extends React.PureComponent<IProps, IState> {
render() {
interface IProps {
superhero: string;
}
interface IState {
health: number;
}
export class MyComponent extends React.PureComponent<IProps, IState> {
readonly state = { health: 100 };
interface IProps {
superhero: string;
}
interface IState {
health: number;
}
const getInitialHealth = (props: IProps) => props.superhero === "Spiderman" ? 0 : 100;
interface IProps {
superhero: string;
}
interface IState {
health: number;
}
export class MyComponent extends React.PureComponent<IProps, IState> {
state: IState;
<!DOCTYPE html>
<html>
<head>
<title>News & Resources</title>
</head>
<body>
<h1>Welcome to News & Resources!</h1>
<p>Have fun!</p>
import * as React from 'react';
export interface Props {
name: string;
}
export class HelloPerson extends React.PureComponent<Props> {
render() {
return (
<div>
import { HelloPerson, Props } from './hello_person.component';
import { shallow } from 'enzyme';
export class HelloPersonDriver {
private wrapper;
private props: Props = {
name: 'some name'
}
given = {
import { HelloPersonDriver } from './hello-person.driver';
describe('Hello Person', () => {
let driver: HelloPersonDriver;
beforeEach(() => {
driver = new HelloPersonDriver();
});
test('should render the name from the prop', () => {
import * as React from 'react';
import { reportUserLogin } from '../services/data-service';
interface Props {
name: string;
}
export class HelloPerson extends React.PureComponent<Props> {
componentDidMount() {
const { name } = this.props;
import { HelloPerson, Props } from './hello_person.component';
import { shallow } from 'enzyme';
import * as dataService from '../services/data-service';
export class HelloPersonDriver {
private wrapper;
private props: Props = {
name: 'some name'
}