diff --git a/package.json b/package.json index 53b71ae..e001472 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "usesync", - "version": "2.0.0", + "version": "2.0.1", "description": "A subscription based state management solution for React!", "main": "src/useSync.js", "type": "module", diff --git a/src/useSync.js b/src/useSync.js index 9189721..cbf11b8 100644 --- a/src/useSync.js +++ b/src/useSync.js @@ -6,8 +6,9 @@ const syncs = {} const useSync = (id, initialValue) => { const [, dispatch] = useReducer(state => !state, false) const value = useRef(initialValue) - const render = (newValue) => { - value.current = newValue + const render = (...args) => { + const [newValue] = args + if (args.length) value.current = newValue dispatch() }