Create-React-App正常使用下無法更改babel設定
且為了保持產生的bundle.js不會太大
Create-React-App並不會將babel-polyfill全部打開
例如以下這些在IE中將會失敗的Function
Array.includes, String.includes, Object.values
以下簡單介紹3種解決辦法

Continue reading

A Simple Higher Order Component example

Simple example

For loading spinner with different Component

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// HOC declaration
function withLoadingSpinner(Component) {
return function EnhancedComponent({ isLoading, ...props }) {
if (!isLoading) {
return <Component { ...props } />;
}
return <LoadingSpinner />;
};
}
// Usage
const ListItemsWithLoadingIndicator = withLoadingSpinner(ListItems);
<ListItemsWithLoadingIndicator
isLoading={props.isLoading}
list={props.list}
/>

Recompose

https://github.com/rafrex/spa-github-pages
A React Library for HOC

Comment and share

Cwza

Hello everyone.
I’m cwza.
Welcome to my blog.


Software Engineer


Taiwan/Taipei