Skip to content

Instantly share code, notes, and snippets.

@MicheleBertoli
MicheleBertoli / index.spec.js
Created September 8, 2018 10:40
Styled Component v4
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 August 30, 2018 13:12
React Automata
import React from 'react'
import { Action, withStatechart } from 'react-automata'
const statechart = {
initial: 'idle',
states: {
idle: {
on: {
FETCH: 'fetching',
},
@MicheleBertoli
MicheleBertoli / toBeShallowInstanceOf.spec.js
Created October 10, 2017 19:48
toBeShallowInstanceOf
expect.extend({
toBeShallowInstanceOf(received, argument) {
const pass = Object.getPrototypeOf(received) === argument.prototype
return {
message: () => (pass ? 'OK' : 'KO'),
pass,
}
},
})
@MicheleBertoli
MicheleBertoli / demo.js
Created September 5, 2017 20:37
InfoWindow
const coords = {
lat: 51.5258541,
lng: -0.08040660000006028,
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
@MicheleBertoli
MicheleBertoli / README.md
Created July 16, 2017 10:23
Tested with Jest

tested with jest

@MicheleBertoli
MicheleBertoli / demo.js
Created October 25, 2016 18:31
Gmaps Marker Icons
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({
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Gmaps } from 'react-gmaps';
const App = React.createClass({
getInitialState() {
return {
loaded: false,
};
@MicheleBertoli
MicheleBertoli / demo.js
Created September 28, 2016 07:34
Polyline
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 September 17, 2016 19:03
If all you have is a hammer, everything looks like a <Nail />
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 September 12, 2016 16:21
Gmaps zoom_changed
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());
},