diff --git a/hooks/src/index.js b/hooks/src/index.js index 72511b0e21d..931f9d7ad7e 100644 --- a/hooks/src/index.js +++ b/hooks/src/index.js @@ -367,15 +367,6 @@ export function useErrorBoundary(cb) { ]; } -function hash(s) { - let h = 0, - i = s.length; - while (i > 0) { - h = ((h << 5) - h + s.charCodeAt(--i)) | 0; - } - return h; -} - export function useId() { const state = getHookState(currentIndex++, 11); if (!state._value) { @@ -401,7 +392,7 @@ export function useId() { // Increase the current component depth pointer ids[i - 1]++; - state._value = 'P' + hash(ids.join('')) + currentIndex; + state._value = 'P' + ids.join('') + currentIndex; } return state._value; diff --git a/hooks/test/browser/useId.test.js b/hooks/test/browser/useId.test.js index 4d96b40e452..a78453bf675 100644 --- a/hooks/test/browser/useId.test.js +++ b/hooks/test/browser/useId.test.js @@ -55,12 +55,12 @@ describe('useId', () => { render(, scratch); expect(scratch.innerHTML).to.equal( - '
h
' + '
h
' ); render(, scratch); expect(scratch.innerHTML).to.equal( - '
h
' + '
h
' ); }); @@ -83,12 +83,12 @@ describe('useId', () => { render(, scratch); expect(scratch.innerHTML).to.equal( - '
hhh
' + '
hhh
' ); render(, scratch); expect(scratch.innerHTML).to.equal( - '
hhh
' + '
hhh
' ); }); @@ -121,13 +121,13 @@ describe('useId', () => { render(, scratch); expect(scratch.innerHTML).to.equal( - '
h
' + '
h
' ); set(true); rerender(); expect(scratch.innerHTML).to.equal( - '
hh
' + '
hh
' ); }); @@ -350,7 +350,7 @@ describe('useId', () => { } render(, scratch); - expect(scratch.innerHTML).to.equal('

P481

P15671

'); + expect(scratch.innerHTML).to.equal('

P01

P011

'); }); it('should skip over HTML', () => { @@ -376,7 +376,7 @@ describe('useId', () => { } render(, scratch); - expect(ids).to.deep.equal(['P491', 'P501']); + expect(ids).to.deep.equal(['P11', 'P21']); }); it('should reset for each renderToString roots', () => {