Skip to content

Instantly share code, notes, and snippets.

View BrodaNoel's full-sized avatar
🏠
Working from home

Broda Noel BrodaNoel

🏠
Working from home
  • Remote
View GitHub Profile
@BrodaNoel
BrodaNoel / react-fancy-component-1.sh
Created June 7, 2017 19:53
react-fancy-component-1
cd ~
mkdir react-fancy-component
echo 'v6.10' > .nvmrc
echo '/node_modules' > .gitignore
nvm use
mkdir build
mkdir src
@BrodaNoel
BrodaNoel / react-fancy-component-2.json
Created June 7, 2017 19:57
react-fancy-component-2
{
"presets": ["env"],
"plugins": [
"transform-object-rest-spread",
"transform-react-jsx"
]
}
@BrodaNoel
BrodaNoel / react-fancy-component-3.js
Created June 7, 2017 19:57
react-fancy-component-3
var path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'index.js',
libraryTarget: 'commonjs2' // THIS IS THE MOST IMPORTANT LINE! :mindblow: I wasted more than 2 days until realize this was the line most important in all this guide.
},
module: {
rules: [
@BrodaNoel
BrodaNoel / react-fancy-component-5.sh
Created June 7, 2017 19:59
react-fancy-component-5
npm i
npm run build
npm link
@BrodaNoel
BrodaNoel / react-fancy-component-6.js
Created June 7, 2017 20:00
react-fancy-component-6
import React from 'react';
class Fancy extends React.Component {
render() {
return (
<div>This is so Fancy!</div>
);
}
}
export default Fancy;
@BrodaNoel
BrodaNoel / react-fancy-project-1.sh
Created June 7, 2017 20:01
react-fancy-project-1
cd ~
npm i -g create-react-app
mkdir react-fancy-project-test
cd react-fancy-project-test
nvm use 6.10
create-react-app .
echo 'v6.10' > .nvmrc
npm link react-fancy-component
@BrodaNoel
BrodaNoel / react-fancy-project-2.js
Created June 7, 2017 20:02
react-fancy-project-2
import React, { Component } from 'react';
import Fancy from 'react-fancy-component';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@BrodaNoel
BrodaNoel / react-fancy-component-4.json
Last active January 23, 2018 22:59
react-fancy-component-4
{
"name": "react-fancy-component",
"version": "0.0.1",
"description": "Put a description here",
"main": "build/index.js",
"peerDependencies": {
"react": "^15.5.4"
},
"dependencies": {
"react": "^15.5.4",
// Option 1
render() {
return (
<div className="App">
<h1>The title</h1>
{
this.state.movies.length > 0 && (
<h1>Movie list</h1>
<MovieList data={this.state.movies} />
)
// src/components/Conditional.jsx
const Conditional = (props) => {
return(
!!props.if && props.children
);
}
export default Conditional;
// Implementation: