New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hacksaw-react

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hacksaw-react - npm Package Compare versions

Comparing version 1.0.0-beta.6 to 1.0.0-beta.7

6

lib/cjs/hooks.js

@@ -9,5 +9,5 @@ "use strict";

const storeMap = (0, react_1.useContext)(context_1.context);
const [contextList, setContextList] = (0, react_1.useState)((0, context_map_1.createStoreContextMap)(storeMap, ...args));
const [_, setState] = (0, react_1.useState)({});
(0, react_1.useEffect)(() => {
const listener = () => setContextList((0, context_map_1.createStoreContextMap)(storeMap, ...args));
const listener = () => setState({});
Object.keys(storeMap).forEach(key => {

@@ -26,4 +26,4 @@ if (storeMap[key].context) {

}, [...args]);
return contextList;
return (0, context_map_1.createStoreContextMap)(storeMap, ...args);
}
exports.useStoreContext = useStoreContext;

@@ -56,6 +56,6 @@ "use strict";

it('renders the view after name change', () => {
let renderCount = 0;
let contexts = [];
const TheComponent = ({ names }) => {
(0, hooks_1.useStoreContext)(...names);
renderCount++;
const context = (0, hooks_1.useStoreContext)(...names);
contexts.push(context);
return react_1.default.createElement("div", null);

@@ -65,13 +65,15 @@ };

react_1.default.createElement(TheComponent, { names: props.names })), { names: ['name1', 'name2'] }));
expect(renderCount).toEqual(1);
expect(contexts.length).toEqual(1);
(0, react_2.act)(() => {
wrapper.setProps({ names: ['name2', 'name3'] });
});
expect(renderCount).toEqual(2);
expect(contexts.length).toEqual(2);
expect(contexts[0].articles).not.toEqual(contexts[1].articles);
(0, react_2.act)(() => {
storeMap.articles.context('name2', 'name3').put({ id: 111 });
});
expect(renderCount).toEqual(3);
expect(contexts[1].articles).toBe(contexts[2].articles);
expect(contexts.length).toEqual(3);
});
});
});

@@ -6,5 +6,5 @@ import { useContext, useEffect, useState } from 'react';

const storeMap = useContext(context);
const [contextList, setContextList] = useState(createStoreContextMap(storeMap, ...args));
const [_, setState] = useState({});
useEffect(() => {
const listener = () => setContextList(createStoreContextMap(storeMap, ...args));
const listener = () => setState({});
Object.keys(storeMap).forEach(key => {

@@ -23,3 +23,3 @@ if (storeMap[key].context) {

}, [...args]);
return contextList;
return createStoreContextMap(storeMap, ...args);
}

@@ -51,6 +51,6 @@ import React from 'react';

it('renders the view after name change', () => {
let renderCount = 0;
let contexts = [];
const TheComponent = ({ names }) => {
useStoreContext(...names);
renderCount++;
const context = useStoreContext(...names);
contexts.push(context);
return React.createElement("div", null);

@@ -60,13 +60,15 @@ };

React.createElement(TheComponent, { names: props.names })), { names: ['name1', 'name2'] }));
expect(renderCount).toEqual(1);
expect(contexts.length).toEqual(1);
act(() => {
wrapper.setProps({ names: ['name2', 'name3'] });
});
expect(renderCount).toEqual(2);
expect(contexts.length).toEqual(2);
expect(contexts[0].articles).not.toEqual(contexts[1].articles);
act(() => {
storeMap.articles.context('name2', 'name3').put({ id: 111 });
});
expect(renderCount).toEqual(3);
expect(contexts[1].articles).toBe(contexts[2].articles);
expect(contexts.length).toEqual(3);
});
});
});

@@ -32,3 +32,3 @@ {

},
"version": "1.0.0-beta.6"
"version": "1.0.0-beta.7"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc