Skip to content

Commit 9fc5910

Browse files
Merge pull request #2689 from preactjs/useref-default
2 parents 0842b9a + 42b973d commit 9fc5910

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

hooks/src/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,7 @@ export function useLayoutEffect(callback, args) {
174174

175175
export function useRef(initialValue) {
176176
currentHook = 5;
177-
return useMemo(
178-
() => ({ current: initialValue === undefined ? null : initialValue }),
179-
[]
180-
);
177+
return useMemo(() => ({ current: initialValue }), []);
181178
}
182179

183180
/**

hooks/test/browser/useRef.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('useRef', () => {
3232
expect(values).to.deep.equal([1, 2]);
3333
});
3434

35-
it('defaults to null', () => {
35+
it('defaults to undefined', () => {
3636
const values = [];
3737

3838
function Comp() {
@@ -45,6 +45,6 @@ describe('useRef', () => {
4545
render(<Comp />, scratch);
4646
render(<Comp />, scratch);
4747

48-
expect(values).to.deep.equal([null, 2]);
48+
expect(values).to.deep.equal([undefined, 2]);
4949
});
5050
});

0 commit comments

Comments
 (0)