Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
💥 🔧 safe-timers: refactor using "eager factory"
Browse files Browse the repository at this point in the history
  • Loading branch information
deepsweet committed Aug 19, 2017
1 parent 370e1c2 commit 05b7c96
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/safe-timers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
},
"peerDependencies": {
"react": "^15.6.1",
"recompose": "^0.24.0"
"recompose": "^0.25.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { Component } from 'react';
import { setDisplayName, wrapDisplayName } from 'recompose';
import { Component } from 'react';
import { createEagerFactory, setDisplayName, wrapDisplayName } from 'recompose';

const safeTimerFactory = (setFn, clearFn, propName, hocName) => (Target) => {
const factory = createEagerFactory(Target);

class SafeTimer extends Component {
constructor(props, context) {
super(props, context);
Expand All @@ -26,14 +28,10 @@ const safeTimerFactory = (setFn, clearFn, propName, hocName) => (Target) => {
}

render() {
const props = {
return factory({
...this.props,
[propName]: this[propName]
};

return (
<Target {...props}/>
);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`withSafeAnimationFrame display name should not wrap display name in production env 1`] = `
<SafeTimer>
<Target
requestSafeAnimationFrame={[Function]}
/>
</SafeTimer>
`;
exports[`withSafeAnimationFrame display name should not wrap display name in production env 1`] = `<SafeTimer />`;

exports[`withSafeAnimationFrame display name should wrap display name in non-production env 1`] = `
<withSafeAnimationFrame(Target)>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`withSafeIdleCallback display name should not wrap display name in production env 1`] = `
<SafeTimer>
<Target
requestSafeIdleCallback={[Function]}
/>
</SafeTimer>
`;
exports[`withSafeIdleCallback display name should not wrap display name in production env 1`] = `<SafeTimer />`;

exports[`withSafeIdleCallback display name should wrap display name in non-production env 1`] = `
<withSafeIdleCallback(Target)>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`withSafeInterval display name should not wrap display name in production env 1`] = `
<SafeTimer>
<Target
setSafeInterval={[Function]}
/>
</SafeTimer>
`;
exports[`withSafeInterval display name should not wrap display name in production env 1`] = `<SafeTimer />`;

exports[`withSafeInterval display name should wrap display name in non-production env 1`] = `
<withSafeInterval(Target)>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`withSafeTimeout display name should not wrap display name in production env 1`] = `
<SafeTimer>
<Target
setSafeTimeout={[Function]}
/>
</SafeTimer>
`;
exports[`withSafeTimeout display name should not wrap display name in production env 1`] = `<SafeTimer />`;

exports[`withSafeTimeout display name should wrap display name in non-production env 1`] = `
<withSafeTimeout(Target)>
Expand Down

0 comments on commit 05b7c96

Please sign in to comment.