\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{KNiGHT BLOOD (spegusess)} \pdfinfo{ /Title (reactjs.pdf) /Creator (Cheatography) /Author (KNiGHT BLOOD (spegusess)) /Subject (ReactJS Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{1F8DA3} \definecolor{LightBackground}{HTML}{F1F7F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{ReactJS Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{KNiGHT BLOOD (spegusess)} via \textcolor{DarkBackground}{\uline{cheatography.com/108914/cs/21609/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}KNiGHT BLOOD (spegusess) \\ \uline{cheatography.com/spegusess} \\ \uline{\seqsplit{blackvisionlab}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 17th January, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Easy Install}} \tn % Row 0 \SetRowColor{LightBackground} create app & npm create-react-app my-app \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} delete src & del src/* \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} creating files & type nul \textgreater{} index.css \{\{nl\}\} type nul \textgreater{} index.js \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} index.js & `import React from 'react'; \{\{nl\}\}import ReactDOM from 'react-dom'; \{\{nl\}\}import './index.css';` \tn % Row Count 8 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Build}} \tn % Row 0 \SetRowColor{LightBackground} run server & npm start \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} create bundle & npm run build \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deploy}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Setup from Scratch}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Initializing} & npm init \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Install React & npm install react react-dom -{}-save \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Install webpack & npm install webpack webpack-dev-server webpack-cli -{}-save \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Install babel & npm install babel-core babel-loader babel-preset-env babel-preset-react html-webpack-plugin -{}-save-dev \tn % Row Count 10 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Structure}} \tn % Row 0 \SetRowColor{LightBackground} index.html & type nul \textgreater{} index.html \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} App.js & type nul \textgreater{} App.js \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} main.js & type nul \textgreater{} main.js \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \seqsplit{webpack.config.js} & type nul \textgreater{} webpackconfig.js \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} .babelrc & type nul \textgreater{} .babelrc \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{React}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/spegusess_1579279202_kisspng-react-logo-redux-webpack-babel--5b7b7258327b51.9184659615348168562068.jpg}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Set Compiler, Server \& Loader}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{ File : webpack.config.js }} \newline \newline const path = require('path'); \newline const HtmlWebpackPlugin = \seqsplit{require('html-webpack-plugin');} \newline \newline module.exports = \{ \newline entry: './main.js', \newline output: \{ \newline path: path.join(\_\_dirname, '/bundle'), \newline filename: 'index\_bundle.js' \newline \}, \newline devServer: \{ \newline inline: true, \newline port: 8001 \newline \}, \newline module: \{ \newline rules: {[} \newline \{ \newline test: /\textbackslash{}.jsx?\$/, \newline exclude: /node\_modules/, \newline loader: 'babel-loader', \newline query: \{ \newline presets: {[}'es2015', 'react'{]} \newline \} \newline \} \newline {]} \newline \}, \newline plugins:{[} \newline new HtmlWebpackPlugin(\{ \newline template: './index.html' \newline \}) \newline {]} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{package.json}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{ \newline "name": "reactApp", \newline "version": "1.0.0", \newline "description": "First React App", \newline "main": "index.js", \newline "scripts": \{ \newline \newline /{\emph{"test": "echo \textbackslash{}"Error: no test specified\textbackslash{}" \&\& exit 1" \newline REMOVE THIS AND ADD FOLLOWING 2 LINES }}/ \newline \newline "start": "webpack-dev-server -{}-mode development -{}-open -{}-hot", \newline "build": "webpack -{}-mode production" \newline \}, \newline "keywords": {[}{]}, \newline "author": "KNiGHTblood", \newline "license": "ISC", \newline "dependencies": \{ \newline "react": "\textasciicircum{}16.12.0", \newline "react-dom": "\textasciicircum{}16.12.0", \newline "webpack": "\textasciicircum{}4.41.5", \newline "webpack-cli": "\textasciicircum{}3.3.10", \newline "webpack-dev-server": "\textasciicircum{}3.10.1" \newline \}, \newline "devDependencies": \{ \newline "babel-core": "\textasciicircum{}6.26.3", \newline "babel-loader": "\textasciicircum{}8.0.6", \newline "babel-preset-env": "\textasciicircum{}1.7.0", \newline "babel-preset-react": "\textasciicircum{}6.24.1", \newline "html-webpack-plugin": "\textasciicircum{}3.2.0" \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{index.html}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}!DOCTYPE html\textgreater{} \newline \textless{}html lang = "en"\textgreater{} \newline \textless{}head\textgreater{} \newline \textless{}meta charset = "UTF-8"\textgreater{} \newline \textless{}title\textgreater{}React App\textless{}/title\textgreater{} \newline \textless{}/head\textgreater{} \newline \textless{}body\textgreater{} \newline \textless{}div id = "app"\textgreater{}\textless{}/div\textgreater{} \newline \textless{}script src = 'index\_bundle.js'\textgreater{}\textless{}/script\textgreater{} \newline \textless{}/body\textgreater{} \newline \textless{}/html\textgreater{}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{App.js}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import React, \{ Component \} from 'react'; \newline class App extends Component\{ \newline render()\{ \newline return( \newline \textless{}div\textgreater{} \newline \textless{}h1\textgreater{}Hello World\textless{}/h1\textgreater{} \newline \textless{}/div\textgreater{} \newline ); \newline \} \newline \} \newline export default App;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{main.js}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{import React from 'react'; \newline import ReactDOM from 'react-dom'; \newline import App from './App.js'; \newline \newline ReactDOM.render(\textless{}App /\textgreater{}, \seqsplit{document.getElementById('app'));}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{.babelrc}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\{ \newline "presets":{[}"env", "react"{]} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.69218 cm} x{3.28482 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Compnents are made with jsx}} \tn % Row 0 \SetRowColor{LightBackground} HTML flips to js Like & `\textless{}div\textgreater{} \{'Hello'.toUpperCase()\} \textless{}/div\textgreater{}` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & `\textless{}div className="hello-{}-upper"\textgreater{} \{'Hello'.toUpperCase()\} \textless{}/div\textgreater{}` \tn % Row Count 5 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}