Skip to content

Instantly share code, notes, and snippets.

Avatar
🏖️
I'm taking a break from OSS.

Michele Bertoli MicheleBertoli

🏖️
I'm taking a break from OSS.
View GitHub Profile
View index.spec.js
import React from 'react'
import styled from 'styled-components'
import renderer from 'react-test-renderer'
import { shallow, mount } from 'enzyme'
import { render } from 'react-testing-library'
const Button = styled.button`
color: red;
`
@MicheleBertoli
MicheleBertoli / App.jsx
Last active Aug 30, 2018
React Automata
View App.jsx
import React from 'react'
import { Action, withStatechart } from 'react-automata'
const statechart = {
initial: 'idle',
states: {
idle: {
on: {
FETCH: 'fetching',
},
View toBeShallowInstanceOf.spec.js
expect.extend({
toBeShallowInstanceOf(received, argument) {
const pass = Object.getPrototypeOf(received) === argument.prototype
return {
message: () => (pass ? 'OK' : 'KO'),
pass,
}
},
})
View demo.js
const coords = {
lat: 51.5258541,
lng: -0.08040660000006028,
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
@MicheleBertoli
MicheleBertoli / demo.js
Created Oct 25, 2016
Gmaps Marker Icons
View demo.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Gmaps, Marker } from 'react-gmaps';
const coords = {
lat: 51.5258541,
lng: -0.08040660000006028,
};
const App = React.createClass({
View demo.js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Gmaps } from 'react-gmaps';
const App = React.createClass({
getInitialState() {
return {
loaded: false,
};
View demo.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Gmaps } from 'react-gmaps';
const App = React.createClass({
onMapCreated(map) {
const flightPlanCoordinates = [
{ lat: 37.772, lng: -122.214 },
{ lat: 21.291, lng: -157.821 },
@MicheleBertoli
MicheleBertoli / decribe.js
Created Sep 17, 2016
If all you have is a hammer, everything looks like a <Nail />
View decribe.js
import React, { PropTypes } from 'react'
const Describe = ({ title, children }) => (
<div>
<h1>{title}</h1>
<ul>{children}</ul>
</div>
)
Describe.propTypes = {
@MicheleBertoli
MicheleBertoli / demo.js
Last active Sep 12, 2016
Gmaps zoom_changed
View demo.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Gmaps } from 'react-gmaps';
const App = React.createClass({
handleZoomChanged() {
console.log('zoom:', this.refs.Gmaps.getMap().getZoom());
},