2020-01-01から1年間の記事一覧

Redux Persistor

*Saves redux state to local or session storages Local Storage ・Data is stored in tabs and windows ・The data will not expire. ・Data remains after browser restart Session Storage ・Data is stored in current tab only ・Data remains after b…

Redux Reselect

*to memoize state so that every time mapStateToProps is called it does not re-render components that do not need to be re-rendered Install reselect npm i reselect Create selectors hoge.selectors.js import { createSelector } from 'reselect'…

Redux Practice Example 3

Provider to index.js index.js import { Provider } from 'react-redux'; import { store } from './redux/store.js'; <Provider store={store}> <App /> </Provider>, Connect to components hoge.js *use the state or dispatch as props of the component const mapStateToProps = (state) => ({ ho…

Redux Practice Example 2

Creating ActionTypes hoge.types.js export const HogeActionTypes = { HOGE: 'HOGE', }; Creating Actions (for dispatching) hoge.actions.js import HogeActionTypes from './hoge.types.js'; export const hoge = () => ({ type: CartActionTypes.HOGE,…

Redux Practice Example

Installing Redux npm i redux redux-logger react-redux Creating store store.js import { createStore, applyMiddleware } from 'redux'; import logger from 'redux-logger'; import rootReducer from './root-reducer.js'; const middleWares = [logger…

Redux Notes

*redux notes Redux Redux Introduction ・state management ・get rid of all states in components ・put them in a store and pass the state to the component that needs it Why Redux ・Good for managing large state ・Useful for sharing data betw…

Routing Notes

*gibberish notes on routing Routing - React is just a UI library - Angular comes with routing (framework) - Before SPA had a problem with back button (url did not change) - Browser has History API - SPA routing libraries use history API to…

Sign in with Google Popup using Firebase

const provider = new firebase.auth.GoogleAuthProvider(); provider.setCustomParameters({ prompt: 'select_account' }); export const signInWithGoogle = () => auth.signInWithPopup(provider); - import { signInWithGoogle } from '../hoge/hoge/fir…

Adding SVG as React Component

- add hoge.svg in assets folder (if you have one) in react project - import { ReactComponent as Logo } from '..../assets/hoge.svg' - < Logo /> (use as component)

React Notes

*Just some gibberish notes I took about React The Birth of React * came out in 2013 * before there was JS, HTML, CSS * browsers worked differently so had to implement it on JS * JQuery worked through all browsers * BackBonejs organize big …

Firebase Cloud Firestoreをインストールからデプロイまで

※自分用メモ Firebase は Google のモバイル・ Web アプリのバックエンドサービス。Firebase を使うとバックエンドを作成する必要も管理するがない。 Firebaseプロジェクト作成 ・Firebaseのページに移動 ・Get Started (gmail accountが必要) ・Add Project…

UnityでRail Shooterゲームの飛行機の動かし方

※自分用メモ UnityでRail Shooterゲームの飛行機を上下左右に動かす using UnityEngine; using UnityStandardAssets.CrossPlatformInput; public class Player : MonoBehaviour { [Header("General")] [Tooltip("In ms^-1")][SerializeField] float speed; […

Unityで障害物を行ったり来たりさせる

※自分用メモ Unityで障害物をいったりきたりさせる using UnityEngine; [DisallowMultipleComponent] public class Oscillator : MonoBehaviour { [SerializeField] Vector3 movementVector; // where to move [SerializeField] float period; // seconds it…