Skip to content

Instantly share code, notes, and snippets.

View MicheleBertoli's full-sized avatar
🏖️
I'm taking a break from OSS.

Michele Bertoli MicheleBertoli

🏖️
I'm taking a break from OSS.
View GitHub Profile
@MicheleBertoli
MicheleBertoli / demo.js
Created August 31, 2016 10:49
Erdux - Unpredictable state container for JavaScript apps
class DecrementAction extends Error {}
class IncrementAction extends Error {}
const reducer = (state, error) => {
switch (error.constructor) {
case DecrementAction:
return state - 1
case IncrementAction:
return state + 1
@MicheleBertoli
MicheleBertoli / demo.js
Created August 12, 2016 10:47
Gmaps setIcon
import React from 'react';
import ReactDOM from 'react-dom';
import { Gmaps, Marker } from 'react-gmaps';
const coords = {
lat: 51.5258541,
lng: -0.08040660000006028
};
const beach = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';
const proxied = target => {
const handler = {
get(target, key) {
if (typeof target[key] === 'function') {
return function (...args) {
const result = target[key].apply(this, args)
console.log('function', key, args, result)
return result
}
}
@MicheleBertoli
MicheleBertoli / demo.js
Created May 7, 2016 06:52
Gmaps pan to
import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps, Marker, InfoWindow} from 'react-gmaps';
const points = [{
lat: 51.5258541,
lng: -0.09040660000006028
}, {
lat: 51.5258541,
lng: -0.08040660000006028
@MicheleBertoli
MicheleBertoli / demo.js
Last active September 17, 2016 21:37
Gmaps set center
import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps, Marker, InfoWindow} from 'react-gmaps';
const points = [{
lat: 51.5258541,
lng: -0.09040660000006028
}, {
lat: 51.5258541,
lng: -0.08040660000006028
@MicheleBertoli
MicheleBertoli / demo.js
Created March 8, 2016 09:55
Add Markers
import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps, Marker} from 'react-gmaps';
const coords = {
lat: 51.5258541,
lng: -0.08040660000006028
};
const Map = React.createClass({
@MicheleBertoli
MicheleBertoli / demo.js
Last active February 2, 2021 09:21
Multiple Info Windows
import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps, Marker, InfoWindow} from 'react-gmaps';
const points = [{
lat: 51.5258541,
lng: -0.09040660000006028
}, {
lat: 51.5258541,
lng: -0.08040660000006028
@MicheleBertoli
MicheleBertoli / app.js
Created February 19, 2016 15:47
React Repeat
const App = React.createClass({
render() {
return (
<Repeat collection={[1, 2]}>
{item => <div>{item}</div>}
</Repeat>
);
}
});
@MicheleBertoli
MicheleBertoli / demo.js
Created February 16, 2016 21:37
Re-rendering
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({
@MicheleBertoli
MicheleBertoli / demo.js
Last active February 16, 2016 21:13
Get Map instance
import React from 'react';
import ReactDOM from 'react-dom';
import {Gmaps} from 'react-gmaps';
const App = React.createClass({
getInitialState() {
return {
isMapCreated: false
};