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

use-context-selector

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-context-selector - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

8

dist/src/index.d.ts

@@ -1,2 +0,8 @@

import { Context } from 'react';
import { ComponentType } from 'react';
export interface Context<Value> {
Provider: ComponentType<{
value: Value;
}>;
displayName?: string;
}
/**

@@ -3,0 +9,0 @@ * This creates a special context for selector-enabled `useContext`.

2

package.json
{
"name": "use-context-selector",
"description": "React useContext with selector support in userland",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"publishConfig": {

@@ -6,0 +6,0 @@ "tag": "next"

@@ -182,3 +182,3 @@ # use-context-selector

- The [stale props](https://react-redux.js.org/api/hooks#stale-props-and-zombie-children) issue isn't solved.
- Due to the current useMutableSource limitation, a selector can't return a function. (See `02_basic_spec` wrapping setState)
- Due to the current useMutableSource limitation, a selector can't return a function. (See `01_basic_spec` wrapping setState)
- Tearing is only avoided within the Provider tree. A value outside the Provider will tear. (`02_tearing_spec` fails)

@@ -185,0 +185,0 @@

/* eslint-disable @typescript-eslint/ban-ts-ignore */
import {
Context,
ComponentType,
Context as ContextOrig,
FC,

@@ -44,2 +45,7 @@ MutableRefObject,

export interface Context<Value> {
Provider: ComponentType<{ value: Value }>;
displayName?: string;
}
const createProvider = <Value>(ProviderOrig: Provider<ContextValue<Value>>) => {

@@ -81,10 +87,6 @@ const RefProvider: FC<{ value: Value }> = ({ value, children }) => {

const source = createMutableSource({ current: defaultValue }, () => defaultValue);
const context = createContextOrig(
{ [SOURCE_SYMBOL]: source },
) as unknown as Context<Value>; // HACK typing
context.Provider = createProvider(
context.Provider as unknown as Provider<ContextValue<Value>>, // HACK typing
) as Provider<Value>;
const context = createContextOrig({ [SOURCE_SYMBOL]: source });
(context as unknown as Context<Value>).Provider = createProvider(context.Provider);
delete context.Consumer; // no support for Consumer
return context;
return context as unknown as Context<Value>;
}

@@ -127,4 +129,4 @@

const { [SOURCE_SYMBOL]: source } = useContextOrig(
context,
) as unknown as ContextValue<Value>; // HACK typing
context as unknown as ContextOrig<ContextValue<Value>>,
);
if (process.env.NODE_ENV !== 'production') {

@@ -131,0 +133,0 @@ if (!source) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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