Skip to content

Instantly share code, notes, and snippets.

View danielnmai's full-sized avatar
💻
Working on React and Node

Daniel Mai danielnmai

💻
Working on React and Node
View GitHub Profile
@danielnmai
danielnmai / gist:cb77615fa4af2dd6eea9d5eb4bf90d8b
Created August 4, 2017 04:57
The Difference Engine - What I learned
Create alias to make shortcut to regular-typed commands
Steps:
1. Go to root directory ( cd ~ )
2. Open the bash profile ( subl ~/.bash_profile )
3. Create alias for command shortcut (for example, the line /alias gs='git status'/ will add an alias "gs" to the command "git status", so you can use "gs" to achieve the same purpose as "git status"
@danielnmai
danielnmai / TIL
Created September 26, 2017 03:51
Today I Learned
git add -p
This is useful!
@danielnmai
danielnmai / server_index.js
Last active September 8, 2018 16:44
Express server for React SSR
import express from "express"
import { renderToString } from "react-dom/server"
import React from 'react'
import App from '../App.js'
import ContextProvider from '../ContextProvider.js'
const app = express()
//Serve the app with the public bundle.js
app.use(express.static("online/dist/"))
@danielnmai
danielnmai / client_index.js
Created September 8, 2018 16:44
Root file for client side
import React from 'react';
import { hydrate } from 'react-dom'
import App from './App.js'
import ContextProvider from './ContextProvider.js'
const context = {
insertCss: (...styles) => {
const removeCss = styles.map(x => x._insertCss());
return () => {
removeCss.forEach(f => f());
@danielnmai
danielnmai / ContextProvider.js
Created September 8, 2018 16:45
Context Provider for App.js
import React from 'react';
import PropTypes from 'prop-types'
import App from './App'
class ContextProvider extends React.Component {
static childContextTypes = {
insertCss: PropTypes.func,
}
getChildContext() {
@danielnmai
danielnmai / reactComponent.js
Last active September 8, 2018 16:47
a simple React component
import React from 'react'
import s from './styles/footer.css'
import withStyles from 'isomorphic-style-loader/lib/withStyles'
const Footer = (props) => {
return (
<div className='footer'>
<p>Copyright @ DANIEL MAI - 2018 All Rights Reserved. </p>
</div>
)