Skip to content

Commit feb9a77

Browse files
committed
input could be object or function, to be able to pass props
1 parent 77e565a commit feb9a77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/GoogleApiComponent.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ const defaultCreateCache = (options) => {
2222
});
2323
};
2424

25-
export const wrapper = (options) => (WrappedComponent) => {
26-
const createCache = options.createCache || defaultCreateCache;
25+
export const wrapper = (input) => (WrappedComponent) => {
2726

2827
class Wrapper extends React.Component {
2928
constructor(props, context) {
3029
super(props, context);
3130

31+
const options = typeof input === 'function' ? input(props) : input;
32+
const createCache = options.createCache || defaultCreateCache;
33+
3234
this.scriptCache = createCache(options);
3335
this.scriptCache.google.onLoad(this.onLoad.bind(this))
3436

0 commit comments

Comments
 (0)