Skip to content

Commit

Permalink
Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
imbhargav5 committed Feb 6, 2019
1 parent b094c85 commit e6f294a
Show file tree
Hide file tree
Showing 48 changed files with 477 additions and 183 deletions.
5 changes: 3 additions & 2 deletions packages/boundingclientrect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for boundingclientrect",
"name": "@rooks/use-boundingclientrect",
"homepage": "https://react-hooks.org/hook/use-boundingclientrect",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
11 changes: 4 additions & 7 deletions packages/boundingclientrect/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ function useBoundingclientRect(ref) {
setValue(getBoundingClientRect());
}

useEffect(
() => {
update();
},
[ref.current]
);
useEffect(() => {
update();
}, [ref.current]);

useMutationObserver(ref, update);

return value;
}

module.exports = useBoundingclientRect;
export default useBoundingclientRect;
5 changes: 3 additions & 2 deletions packages/counter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for counter",
"name": "@rooks/use-counter",
"homepage": "https://react-hooks.org/hook/use-counter",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/counter/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ function useCounter(initialValue) {
};
}

module.exports = useCounter;
export default useCounter;
5 changes: 3 additions & 2 deletions packages/did-mount/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React hooks package for componentDidMount",
"name": "@rooks/use-did-mount",
"homepage": "https://react-hooks.org/hook/use-did-mount",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/did-mount/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ function useDidMount(callback) {
}, []);
}

module.exports = useDidMount;
export default useDidMount;
5 changes: 3 additions & 2 deletions packages/did-update/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "componentDidUpdate hook for react",
"name": "@rooks/use-did-update",
"homepage": "https://react-hooks.org/hook/use-did-update",
Expand All @@ -10,7 +11,7 @@
},
"scripts": {
"test": "jest",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/did-update/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ function useDidUpdate(callback, conditions) {
}, conditions);
}

module.exports = useDidUpdate;
export default useDidUpdate;
5 changes: 3 additions & 2 deletions packages/input/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for input",
"name": "@rooks/use-input",
"homepage": "https://react-hooks.org/hook/use-input",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
11 changes: 4 additions & 7 deletions packages/input/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ function useInput(initialValue = "", opts = defaultOptions) {
}
}
//sync with default value
useEffect(
() => {
setValue(initialValue);
},
[initialValue]
);
useEffect(() => {
setValue(initialValue);
}, [initialValue]);

return { value, onChange };
}

module.exports = useInput;
export default useInput;
5 changes: 3 additions & 2 deletions packages/interval/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A react hook for using setInterval",
"name": "@rooks/use-interval",
"homepage": "https://react-hooks.org/hook/use-interval",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
23 changes: 10 additions & 13 deletions packages/interval/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ function useInterval(cb, intervalDuration, startImmediate = false) {
}
}

useEffect(
() => {
if (isRunning) {
const _intervalId = setInterval(cb, intervalDuration);
setIntervalId(_intervalId);
return () => {
clearInterval(_intervalId);
};
}
},
[isRunning]
);
useEffect(() => {
if (isRunning) {
const _intervalId = setInterval(cb, intervalDuration);
setIntervalId(_intervalId);
return () => {
clearInterval(_intervalId);
};
}
}, [isRunning]);

return {
start,
Expand All @@ -33,4 +30,4 @@ function useInterval(cb, intervalDuration, startImmediate = false) {
};
}

module.exports = useInterval;
export default useInterval;
5 changes: 3 additions & 2 deletions packages/key/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "Keyboard key handler hook for react",
"name": "@rooks/use-key",
"homepage": "https://react-hooks.org/hook/use-key",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/key/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ function useKey(keyList = [], handler, opts) {
}, [when, eventTypes, keyList, targetNode, handler]);
}

module.exports = useKey;
export default useKey;
5 changes: 3 additions & 2 deletions packages/localstorage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "Local Storage hook for React",
"name": "@rooks/use-localstorage",
"homepage": "https://react-hooks.org/hook/use-localstorage",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/localstorage/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ function useLocalStorage(key, defaultValue = null) {
};
}

module.exports = useLocalStorage;
export default useLocalStorage;
5 changes: 3 additions & 2 deletions packages/mouse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for mouse",
"name": "@rooks/use-mouse",
"homepage": "https://react-hooks.org/hook/use-mouse",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
4 changes: 3 additions & 1 deletion packages/mutation-observer/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"main": "lib/index.js",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"license": "MIT",
"description": "A React Hooks package for mutation-observer",
"name": "@rooks/use-mutation-observer",
Expand All @@ -11,7 +13,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
35 changes: 17 additions & 18 deletions packages/mutation-observer/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ var config = {
childList: true
};

module.exports = function(ref, callback, options = config) {
useEffect(
() => {
// Create an observer instance linked to the callback function
if (ref.current) {
const observer = new MutationObserver((mutationList, observer) => {
callback(mutationList, observer);
});
function useMutationObserver(ref, callback, options = config) {
useEffect(() => {
// Create an observer instance linked to the callback function
if (ref.current) {
const observer = new MutationObserver((mutationList, observer) => {
callback(mutationList, observer);
});

// Start observing the target node for configured mutations
observer.observe(ref.current, options);
return () => {
observer.disconnect();
};
}
},
[ref.current, callback, options]
);
};
// Start observing the target node for configured mutations
observer.observe(ref.current, options);
return () => {
observer.disconnect();
};
}
}, [ref.current, callback, options]);
}

export default useMutationObserver;
5 changes: 3 additions & 2 deletions packages/navigator-language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for navigator-language",
"name": "@rooks/use-navigator-language",
"homepage": "https://react-hooks.org/hook/use-navigator-language",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
5 changes: 3 additions & 2 deletions packages/online/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "A React Hooks package for online",
"name": "@rooks/use-online",
"homepage": "https://react-hooks.org/hook/use-online",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion packages/online/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ function useOnline() {
return online;
}

module.exports = useOnline;
export default useOnline;
5 changes: 3 additions & 2 deletions packages/outside-click/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"main": "lib/index.js",
"license": "MIT",
"jsnext:main": "lib/index.esm.js",
"module": "lib/index.esm.js",
"description": "React hook for tracking clicks outside a ref",
"name": "@rooks/use-outside-click",
"homepage": "https://react-hooks.org/hook/use-outside-click",
Expand All @@ -11,7 +12,7 @@
"scripts": {
"test": "jest",
"lint": "eslint src test",
"build": "babel src --out-dir lib",
"build": "rollup -c ../../scripts/rollup.config.js",
"prepublish": "yarn run build"
},
"keywords": [
Expand Down
Loading

0 comments on commit e6f294a

Please sign in to comment.