Skip to content

Instantly share code, notes, and snippets.

@shubhnik
shubhnik / slim-redux.js
Created October 29, 2017 18:57 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@shubhnik
shubhnik / connect.js
Created October 29, 2017 18:57 — forked from gaearon/connect.js
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 (
@shubhnik
shubhnik / ProportionalImage.js
Last active October 23, 2017 11:02 — forked from mikelambert/ProportionalImage.js
Renders an Image that stays proportionally sized to its original dimensions. Also check this issue ----> https://github.com/facebook/react-native/issues/858
var ProportionalImage = React.createClass({
getInitialState() {
return {
style: {}
};
},
propTypes: {
originalWidth: React.PropTypes.number.isRequired,