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

wc-react

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wc-react - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

0

dist/esm/index.d.ts
export * from './Wc';
export * from './Wc';
//# sourceMappingURL=index.js.map

3

dist/esm/Wc.d.ts

@@ -7,2 +7,3 @@ import React, { Component } from 'react';

wcType: string | Function;
innerRef: React.Ref<unknown>;
};

@@ -108,2 +109,2 @@ /**

*/
export declare const wrapWc: <T = WcProps>(tag: TimerHandler) => React.FC<T & React.HTMLAttributes<any>>;
export declare const wrapWc: <T = WcProps>(tag: string | Function) => React.ForwardRefExoticComponent<React.PropsWithoutRef<T & React.HTMLAttributes<any>> & React.RefAttributes<unknown>>;

@@ -73,2 +73,10 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */

}
if (this.props.innerRef) {
if (typeof this.props.innerRef === 'function') {
this.props.innerRef(element);
}
else {
this.props.innerRef.current = element;
}
}
}

@@ -198,6 +206,7 @@ /**

*/
// eslint-disable-next-line @typescript-eslint/ban-types
export const wrapWc = (tag) => {
const component = (props) => React.createElement(Wc, Object.assign({ wcType: tag }, props));
const component = React.forwardRef((props, ref) => React.createElement(Wc, Object.assign({ wcType: tag, innerRef: ref }, props)));
return component;
};
//# sourceMappingURL=Wc.js.map
{
"name": "wc-react",
"version": "0.4.0",
"version": "0.5.0",
"description": "Web Components wrapper class for React",

@@ -5,0 +5,0 @@ "author": "metulev",

@@ -69,2 +69,34 @@ # React wrapper for web components

## Refs
Wrapped components support passing a `ref` which will get a reference to the underlying web component.
Example with `useRef`:
```jsx
const App = (props) => {
let myRef = React.useRef();
const handleClick = () => {
console.log('web component reference', myRef.current)
}
return <MyComponent ref={myRef} onClick={handleClick}></MyComponent>;
}
```
Example with callback:
```jsx
const App = (props) => {
const onRefChanged = (element) => {
console.log('web component reference', element)
}
return <MyComponent ref={onRefChanged}></MyComponent>;
}
```
## Typescript

@@ -71,0 +103,0 @@

@@ -10,3 +10,5 @@ /* eslint-disable @typescript-eslint/explicit-function-return-type */

export type WcTypeProps = WcProps & {
// eslint-disable-next-line @typescript-eslint/ban-types
wcType: string | Function;
innerRef: React.Ref<unknown>;
};

@@ -98,2 +100,11 @@

}
if (this.props.innerRef) {
if (typeof this.props.innerRef === 'function') {
this.props.innerRef(element);
}
else {
(this.props.innerRef as any).current = element;
}
}
}

@@ -245,6 +256,7 @@

*/
// eslint-disable-next-line @typescript-eslint/ban-types
export const wrapWc = <T = WcProps>(tag: string | Function) => {
const component: React.FC<T & React.HTMLAttributes<any>> =
(props: T) => React.createElement(Wc, { wcType: tag, ...props });
const component: React.ForwardRefExoticComponent<React.PropsWithoutRef<T & React.HTMLAttributes<any>> & React.RefAttributes<unknown>> =
React.forwardRef((props: T, ref) => React.createElement(Wc, { wcType: tag, innerRef: ref, ...props }));
return component;
};

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