Skip to content

Instantly share code, notes, and snippets.

View denisraslov's full-sized avatar

Denis Raslov denisraslov

  • Revolut
  • London, UK
View GitHub Profile
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { getStore } from 'react/store';
import Content from 'react/components/content';
import Header from 'views/header';
const Page = Backbone.View.extend({
render() {
function getInitialState() {
const state = {};
// Let's suggest that APP is our global Backbone app instanse,
// that keeps some models and collections.
// We put the data from them into initial Redux state.
state.account = APP.models.account.attributes;
state.sellPoints = APP.collections.tasks.map(task => task.attributes);
import React from 'react';
import DashboardView from 'views/dashboard';
class DashboardPage extends React.PureComponent {
// render an empty DIV and save a reference to it
render() {
return <div ref={node => this.node = node}></div>;
}
import Header from 'views/header';
import Content from 'views/content';
import Footer from 'views/footer';
const Page = Backbone.View.extend({
render() {
const attributes = this.model.attributes;
this.headerView = new Header(this.$('.header'), attributes);
this.contentView = new Content(this.$('.content'), attributes);
@denisraslov
denisraslov / redux-thunk-dispatch-example.js
Last active May 2, 2016 21:51
redux-thunk dispatch example
import React from 'react'
import { getUser } from 'actions'
class MyComponent extends React.Component {
//...
// Dispatch the imported action function with the Dispatcher
// that you have because of react-redux.
getUser(id) {
this.props.dispatch(getUser(id));
@denisraslov
denisraslov / redux-thunk-actions-example.js
Last active May 2, 2016 22:06
redux-thunk actions example
import request from 'axios';
// Let's assume we need to get the user data through API.
// We create the action function that takes the user id
// and make the async request.
export function getUser(id) {
// We have access to the Dispather to dispath
// actions inside of the action function.
return (dispatch) => {
request