showmethecode
showmethecode copied to clipboard
#TW Meetup #2 20190520
日期 Date
20190520
地點 Location
- Taiwan
場地 Venue
- AppWorks 4/F
題目 Sessions
- in <
> @< > , with one-line to describe
@vincentlaucy will share on yarn workspaces & monorepo setup https://medium.com/wordquest-engineering/structuring-js-app-in-monorepo-yarn-workspaces-react-node-firebase-845e207a4314 @alincode will share writing more functional code in javascript
收 React Hooks 的演講嗎?我有一些奇怪的 hooks 可以講,但還沒寫投影片😂
@caasi sure! 非常歡迎而且不需要投影片,我們直接show code 😂
@vincentlaucy I would going to share seo solution when use Material-ui in nextjs
https://github.com/alincode/20190520-show-me-the-code by @alincode
@qas612820704:
Your talk reminds me that we can treat actions as messages in OOP.
@caasi, can you tell me in detail? :)
A simplified User
class:
class User {
constructor(name) {
this.name = name;
}
name(v) {
this.name = v;
return this;
}
}
An User
reducer:
const USER_NAME = 'USER_NAME';
const Name = (name) => ({
type: USER_NAME,
name,
});
const initialState = {
name: '',
};
const reducer = (state = initialState, action = {}) {
switch(action.type) {
case USER_NAME: {
const { name } = action;
return { ...state, name };
}
default:
return state;
}
}
Their structure are almost the same. So if you dispatch actions by yourself, you can reuse reducers in any reducer. Just like you can delegate messages(call methods) to other objects in OOP paradigm.