mirror of
https://github.com/zhigang1992/react-content-loader.git
synced 2026-03-29 07:48:13 +08:00
Added uniquekey a defaultProp (#81)
This commit is contained in:
committed by
Danilo Woznica
parent
61bd3aae6d
commit
6669f0304e
@@ -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 (
|
||||
<svg
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//@flow
|
||||
import * as React from 'react'
|
||||
import Wrap from './Wrap'
|
||||
import uid from './uid'
|
||||
|
||||
// Stylized
|
||||
export { default as Facebook } from './stylized/FacebookStyle'
|
||||
@@ -29,6 +30,7 @@ const defaultProps = {
|
||||
primaryColor: '#f0f0f0',
|
||||
secondaryColor: '#e0e0e0',
|
||||
preserveAspectRatio: 'xMidYMid meet',
|
||||
uniquekey: uid(),
|
||||
}
|
||||
|
||||
const InitialComponent = props => (
|
||||
|
||||
@@ -71,5 +71,12 @@ describe('<ContentLoader />:', () => {
|
||||
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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user