Skip to content

Commit

Permalink
Merge pull request #5 from suitedjimster/logonmount_dependencies
Browse files Browse the repository at this point in the history
Fix for LogOnChange and LogOnMount dependencies
  • Loading branch information
koblas committed May 11, 2020
2 parents a016851 + cdfea57 commit 5103b1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/components/LogOnChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ type Props = {
};

export const LogOnChange: React.StatelessComponent<Props> = (props: Props) => {
const { logEvent, amplitudeInstance } = useAmplitude(undefined, props.instanceName);
const { logEvent } = useAmplitude(undefined, props.instanceName);

React.useEffect(() => {
logEvent(props.eventType, props.eventProperties);
}, [props.eventType, props.eventProperties, props.value, amplitudeInstance]);
}, [props.value]);

return props.children || (null as any);
};
Expand All @@ -25,5 +25,5 @@ LogOnChange.propTypes = {
eventProperties: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
eventType: PropTypes.string.isRequired,
instanceName: PropTypes.string,
value: PropTypes.any
value: PropTypes.any,
};
6 changes: 3 additions & 3 deletions src/components/LogOnMount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ type Props = {
};

export const LogOnMount: React.StatelessComponent<Props> = (props: Props) => {
const { logEvent, amplitudeInstance } = useAmplitude(undefined, props.instanceName);
const { logEvent } = useAmplitude(undefined, props.instanceName);

React.useEffect(() => {
logEvent(props.eventType, props.eventProperties);
}, [props.eventType, props.eventProperties, amplitudeInstance]);
}, []);

return props.children || (null as any);
};

LogOnMount.propTypes = {
eventProperties: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
eventType: PropTypes.string.isRequired,
instanceName: PropTypes.string
instanceName: PropTypes.string,
};

0 comments on commit 5103b1d

Please sign in to comment.