From 6669f0304e05d382d9f89d7ee743c8d5d6ffbbad Mon Sep 17 00:00:00 2001 From: Nic Mitchell Date: Sat, 3 Feb 2018 07:25:04 -0800 Subject: [PATCH] Added `uniquekey` a defaultProp (#81) --- src/Wrap.js | 5 ++--- src/index.js | 2 ++ tests/index.js | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Wrap.js b/src/Wrap.js index 4db6eac..e870282 100644 --- a/src/Wrap.js +++ b/src/Wrap.js @@ -1,6 +1,5 @@ //@flow import * as React from 'react' -import uid from './uid' import type { Props as ContentLoaderProps } from './index' @@ -9,8 +8,8 @@ export type WrapProps = { } & ContentLoaderProps const Wrap = (props: WrapProps): React.Element<*> => { - const idClip = `${props.uniquekey}-idClip` || uid() - const idGradient = `${props.uniquekey}-idGradient` || uid() + const idClip = `${props.uniquekey}-idClip` + const idGradient = `${props.uniquekey}-idGradient` return ( ( diff --git a/tests/index.js b/tests/index.js index 1f2bb45..8a4285b 100755 --- a/tests/index.js +++ b/tests/index.js @@ -71,5 +71,12 @@ describe(':', () => { it('`style` is a object and used', () => { expect(wrapper.props().style).to.deep.equal({ marginBottom: '10px' }) }) + + it('`uniquekey` does not generate undefined `id` values for svg', () => { + const idClip = wrapper.find('clipPath').prop('id') + const idGradient = wrapper.find('linearGradient').prop('id') + expect(idClip).to.not.contain(undefined) + expect(idGradient).to.not.contain(undefined) + }) }) })