This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use React.Fragment via props while React version is over 16.2.0
- Loading branch information
zhengyuanbing
committed
Dec 30, 2020
1 parent
1b6c2c6
commit 704f758
Showing
6 changed files
with
157 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function compare (a, b) { | ||
const v1 = a.split('.').map(n => Number(n)) | ||
const v2 = b.split('.').map(n => Number(n)) | ||
const len = Math.min(v1.length, v2.length) | ||
let result = 0 | ||
for (let i = 0; i < len; i += 1) { | ||
if (v1[i] === v2[i]) { | ||
continue | ||
} else { | ||
result = v1[i] > v2[i] ? 1 : -1 | ||
break | ||
} | ||
} | ||
return result === 0 ? v1.length - v2.length : result | ||
} | ||
|
||
export function gte (a, b) { | ||
return compare(a, b) >= 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { gte } from '../../src/utils/compare' | ||
|
||
describe('compare', () => { | ||
it('returns true for React version is 16.3.0', () => { | ||
expect(gte('16.3.0', '16.2.0')).toBe(true) | ||
}) | ||
|
||
it('returns true for React version is 15.2.0', () => { | ||
expect(gte('15.2.0', '16.2.0')).toBe(false) | ||
}) | ||
}) |