Skip to content

Instantly share code, notes, and snippets.

View EdwinGuzman's full-sized avatar
🐺
yep

Edwin Guzman EdwinGuzman

🐺
yep
  • The New York Public Library
View GitHub Profile
const bookBy = (author, book) => {
console.log(`${author} wrote ${book}.`);
};
bookBy('Orson Scott Card', 'Ender\'s Game');
// Orson Scott Card wrote Ender's Game.
bookBy('N. K. Jemisin', 'The Fifth Season');
// N. K. Jemisin wrote The Fifth Season.
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
class App extends React.Component {
// ...
render () {
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
const trackHomepageRow = (action) => {
return (label) => {
return trackHomepage(action, label);
};
// App.jsx
import HomepageRow from 'dgx-homepage-row-component';
import HomepageStaffPicks from 'dgx-homepage-staff-picks-component';
import FeatureRow from 'dgx-feature-row';
import Banner from 'dgx-content-banner';
import { gaUtils } from 'dgx-react-ga';
const trackHomepage = gaUtils.trackEvent('Homepage');
const trackHomepageRow = (action) => {
return (label) => {
const bookBy = (author) => {
return (book) => {
console.log(`${author} wrote ${book}.`);
};
};
const booksByRowling = bookBy('J. K. Rowling');
booksByRowling('Harry Potter and the Sorcerer\'s Stone');
// J. K. Rowling wrote Harry Potter and the Sorcerer’s Stone.
booksByRowling('Harry Potter and the Chamber of Secrets');
bookBy('J. K. Rowling', 'Harry Potter and the Sorcerer\'s Stone');
// J. K. Rowling wrote Harry Potter and the Sorcerer's Stone.
bookBy('J. K. Rowling', 'Harry Potter and the Chamber of Secrets');
// J. K. Rowling and the Chamber of Secrets
bookBy('J. K. Rowling', 'Harry Potter and the Prisoner of Azkaban');
// J. K. Rowling wrote Harry Potter and the Prisoner of Azkaban
// Etc.
// Previous way of importing the NYPL Header in package.json:
"dgx-header-component":"git+ssh://git@bitbucket.org/NYPL/dgx-header-component.git#master",
// Installing the npm Header and Footer:
$ npm install --save @nypl/dgx-header-component
$ npm install --save @nypl/dgx-react-footer
// NPM packages in package.json:
"dependencies": {
"@nypl/dgx-header-component": "1.4.1",
// We went from using React 0.13 and React Router 0.13 syntax:
import Router from 'react-router';
// ...
app.use('/', (req, res) => {
let iso = new Iso();
alt.bootstrap(JSON.stringify(res.locals.data || {}));
Router.run(routes.server, req.path, (Root, state) => {
const html = React.renderToString(<Root route={req.path} />);
// React Router v0.13
<Route path="/" name="root" handler={Application}>
<Route path="blog" name="blogHome" handler={BlogsWrapper} />
<!-- more routes -->
</Route>
// React Router v2.0
<Route path="/" component={Application}>
<Route path="blog" component={BlogsWrapper} />
<!-- more routes -->
// ES5
const App = React.createClass({
Mixins: [Navigation],
// ...
});
// ES6
class App extends React.Component {
// ...
}