View flatten.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// could be in the context of a project or just a separate js file to be run with node ${fileName} | |
// for the first, the tools to run and result the tests really depend on the project setup | |
// for the latter, the tests would have to be commented out and lines 15 and 16 uncommented | |
/** | |
* Returns flattened array | |
* @param {*} arr with arr elements | |
*/ | |
export const flatten = arr => { | |
const doFlatten = () => { |
View tslint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"extends": ["tslint:recommended", "tslint-react"], | |
"rulesDirectory": ["tslint-plugin-prettier"], | |
"linterOptions": { | |
"exclude": [ | |
"config/**/*.js", | |
"dist", | |
"tmp", | |
"node_modules/**/*.ts", | |
"node_modules/**/*.tsx", |
View useField.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useField = initial => { | |
const [value, set] = useState(initial); | |
return { | |
value, | |
set, | |
reset: () => set(initial), | |
bind: { | |
value, | |
onChange: e => set(e.target.value) |
View App.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
// first we will make a new context | |
const MyContext = React.createContext(); | |
// Then create a provider Component | |
class MyProvider extends Component { | |
state = { | |
name: 'Wes', | |
age: 100, |
View ErrorBoundary.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export default class ErrorBoundary extends React.Component { | |
constructor(props) { | |
super(); | |
this.state = { error: null, errorInfo: null }; | |
} | |
componentDidCatch(error, info) { | |
this.setState({ | |
error, |
View codePen1.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HelloWorld extends React.Component { | |
render() { | |
const name = 'Sr(a) ' + this.props.name | |
return <h1>Hello, {name}!!</h1>; | |
} | |
} | |
ReactDOM.render( | |
<HelloWorld name="Joao"/>, | |
document.getElementById('root') |
View Basic React Component wrapper for react-bootstrap Modal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage-0 and es2015 babel presets setup. |