Skip to content

Instantly share code, notes, and snippets.

@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@JWally
JWally / ExampleFileMD5.js
Last active July 17, 2023 20:23
Simple Method to Calculate the Hash of a file in Javascript using HTML5 API
//Event Listener tied to the file input field
document.getElementById('attachment').addEventListener('change', eventHandler, false)
/**
*Description: Simple method to handle an event
*and fire off a function
**/
function eventHandler(evt){
var file = evt.target.files[0];
fileHash( file, md5, function(x){