Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rc-component/context

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rc-component/context - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

es/Immutable.d.ts
import * as React from 'react';
/**
* Get render update mark by `makeImmutable` root.
* Do not deps on the return value as render times
* but only use for `useMemo` or `useCallback` deps.
*/
export declare function useImmutableMark(): number;
/**
* Wrapped Component will be marked as Immutable.

@@ -4,0 +10,0 @@ * When Component parent trigger render,

15

es/Immutable.js
import _extends from "@babel/runtime/helpers/esm/extends";
import { supportRef } from "rc-util/es/ref";
import * as React from 'react';
var RenderContext = /*#__PURE__*/React.createContext(0);
var ImmutableContext = /*#__PURE__*/React.createContext(0);
/**
* Get render update mark by `makeImmutable` root.
* Do not deps on the return value as render times
* but only use for `useMemo` or `useCallback` deps.
*/
export function useImmutableMark() {
return React.useContext(ImmutableContext);
}
/**
* Wrapped Component will be marked as Immutable.

@@ -20,3 +29,3 @@ * When Component parent trigger render,

renderTimesRef.current += 1;
return /*#__PURE__*/React.createElement(RenderContext.Provider, {
return /*#__PURE__*/React.createElement(ImmutableContext.Provider, {
value: renderTimesRef.current

@@ -44,3 +53,3 @@ }, /*#__PURE__*/React.createElement(Component, _extends({}, props, refProps)));

} : {};
React.useContext(RenderContext);
useImmutableMark();
return /*#__PURE__*/React.createElement(Component, _extends({}, props, refProps));

@@ -47,0 +56,0 @@ };

4

es/index.d.ts
import type { SelectorContext } from './context';
import { createContext, useContext } from './context';
import { makeImmutable, responseImmutable } from './Immutable';
export { createContext, useContext, makeImmutable, responseImmutable };
import { makeImmutable, responseImmutable, useImmutableMark } from './Immutable';
export { createContext, useContext, makeImmutable, responseImmutable, useImmutableMark };
export type { SelectorContext };
import { createContext, useContext } from "./context";
import { makeImmutable, responseImmutable } from "./Immutable";
export { createContext, useContext, makeImmutable, responseImmutable };
import { makeImmutable, responseImmutable, useImmutableMark } from "./Immutable";
export { createContext, useContext, makeImmutable, responseImmutable, useImmutableMark };
import * as React from 'react';
/**
* Get render update mark by `makeImmutable` root.
* Do not deps on the return value as render times
* but only use for `useMemo` or `useCallback` deps.
*/
export declare function useImmutableMark(): number;
/**
* Wrapped Component will be marked as Immutable.

@@ -4,0 +10,0 @@ * When Component parent trigger render,

@@ -12,2 +12,3 @@ "use strict";

exports.responseImmutable = responseImmutable;
exports.useImmutableMark = useImmutableMark;

@@ -24,4 +25,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var RenderContext = /*#__PURE__*/React.createContext(0);
var ImmutableContext = /*#__PURE__*/React.createContext(0);
/**
* Get render update mark by `makeImmutable` root.
* Do not deps on the return value as render times
* but only use for `useMemo` or `useCallback` deps.
*/
function useImmutableMark() {
return React.useContext(ImmutableContext);
}
/**
* Wrapped Component will be marked as Immutable.

@@ -32,2 +42,3 @@ * When Component parent trigger render,

function makeImmutable(Component) {

@@ -42,3 +53,3 @@ var refAble = (0, _ref.supportRef)(Component);

renderTimesRef.current += 1;
return /*#__PURE__*/React.createElement(RenderContext.Provider, {
return /*#__PURE__*/React.createElement(ImmutableContext.Provider, {
value: renderTimesRef.current

@@ -67,3 +78,3 @@ }, /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({}, props, refProps)));

} : {};
React.useContext(RenderContext);
useImmutableMark();
return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({}, props, refProps));

@@ -70,0 +81,0 @@ };

import type { SelectorContext } from './context';
import { createContext, useContext } from './context';
import { makeImmutable, responseImmutable } from './Immutable';
export { createContext, useContext, makeImmutable, responseImmutable };
import { makeImmutable, responseImmutable, useImmutableMark } from './Immutable';
export { createContext, useContext, makeImmutable, responseImmutable, useImmutableMark };
export type { SelectorContext };

@@ -30,2 +30,8 @@ "use strict";

});
Object.defineProperty(exports, "useImmutableMark", {
enumerable: true,
get: function get() {
return _Immutable.useImmutableMark;
}
});

@@ -32,0 +38,0 @@ var _context = require("./context");

{
"name": "@rc-component/context",
"version": "1.1.0",
"version": "1.2.0",
"description": "React way perf context selector",

@@ -5,0 +5,0 @@ "keywords": [

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