This file contains hidden or 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
| Symbol() == Symbol() | |
| // False | |
| Symbol('abacaba') == Symbol('abacaba') | |
| // False | |
| // But | |
| const s = Symbol('sym'); | |
| s == s | |
| // True |
This file contains hidden or 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
| // string is a primitive data type | |
| const name = 'Michael'; | |
| name.toUpperCase(); | |
| // toUpperCase is not a method; it does not mutate | |
| // the original variable | |
| console.log(name); // Michael | |
| // instead, it returns a new one | |
| const NAME = name.toUpperCase(); | |
| console.log(NAME); // MICHAEL |
This file contains hidden or 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 Car { | |
| constructor(make, model) { | |
| this.make = make; | |
| this.model = model; | |
| } | |
| start() { | |
| console.log('vroom'); | |
| } | |
This file contains hidden or 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
| function iAmAnObject() {} | |
| console.log(iAmAnObject.name); // iAmAnObject | |
| console.log(Object.keys(iAmAnObject)); // Array [] |
This file contains hidden or 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" declaration | |
| function Car(make, model) { | |
| this.make = make; | |
| this.model = model; | |
| } | |
| // the start method | |
| Car.prototype.start = function() { | |
| console.log('vroom'); | |
| } |
This file contains hidden or 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'; | |
| import { View, TextInput, StyleSheet } from 'react-native'; | |
| import {useSelector} from 'react-redux'; | |
| const StateViewer = (props) => { | |
| const formState = useSelector((state) => state.form); | |
| // Prettify the JSON code: | |
| const prettyFormState = JSON.stringify(formState, null, 2); | |
| return ( | |
| <View style={styles.root}> |
This file contains hidden or 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'; | |
| import { Provider } from 'react-redux'; | |
| import store from './store'; | |
| import Form from './Form'; | |
| export default function App() { | |
| return ( | |
| <Provider store={store}> | |
| <Form /> | |
| </Provider> |
This file contains hidden or 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'; | |
| import { View, Button, TextInput, StyleSheet } from 'react-native'; | |
| import { Field, reduxForm } from 'redux-form'; | |
| const Form = (props) => { | |
| const { handleSubmit } = props; | |
| const onSubmit = (values) => console.log(values); |
This file contains hidden or 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'; | |
| import Form from './Form'; | |
| export default function App() { | |
| return ( | |
| <Form /> | |
| ); | |
| } |
This file contains hidden or 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 {combineReducers, createStore} from 'redux'; | |
| import {reducer as formReducer} from 'redux-form'; | |
| const rootReducer = combineReducers({ | |
| // ... the rest of your reducers | |
| form: formReducer | |
| }); | |
| const store = createStore(rootReducer); |