This repository was archived by the owner on Nov 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-11
lines changed Expand file tree Collapse file tree 3 files changed +41
-11
lines changed Original file line number Diff line number Diff line change 11# @tippy .js/react
22
3- React wrapper component for Tippy.js 3.
3+ React component for Tippy.js 3.
44
55## Installation
66
@@ -10,7 +10,7 @@ npm i @tippy.js/react
1010
1111CDN: https://unpkg.com/@tippy.js/react
1212
13- Requires React 16.3+ and ` prop-types ` if using via CDN.
13+ Requires React 16.3+, ` prop-types ` , and ` tippy.js ` if using via CDN.
1414
1515## Usage
1616
@@ -65,8 +65,35 @@ const App = () => (
6565ReactDOM .render (< App / > , document .getElementById (' root' ))
6666```
6767
68- See the [ Tippy.js docs] ( https://atomiks.github.io/tippyjs/ ) for the rest of the props
69- you can supply.
68+ ### Component as a child
69+
70+ Use ` React.forwardRef() ` :
71+
72+ ``` jsx
73+ const withForwardRef = Comp => {
74+ return React .forwardRef ((props , ref ) => (
75+ < Comp {... props} forwardedRef= {ref} / >
76+ ))
77+ }
78+
79+ const Button = withForwardRef (
80+ class extends React .Component {
81+ render () {
82+ return < button ref= {this .props .forwardedRef }> My button< / button>
83+ }
84+ }
85+ )
86+
87+ const App = () => (
88+ < main>
89+ < Tippy>
90+ < Button / >
91+ < / Tippy>
92+ < / main>
93+ )
94+ ```
95+
96+ See the [ Tippy.js docs] ( https://atomiks.github.io/tippyjs/ ) for the rest of the props you can supply.
7097
7198## License
7299
Original file line number Diff line number Diff line change @@ -19,17 +19,18 @@ const pluginResolve = resolve()
1919const rollupConfig = ( ...plugins ) => ( {
2020 input : './src/Tippy.js' ,
2121 plugins : [ pluginBabel , pluginResolve , ...plugins ] ,
22- external : [ 'react' , 'prop-types' ]
22+ external : [ 'tippy.js' , ' react' , 'react-dom ', 'prop-types' ]
2323} )
2424const output = format => file => ( {
2525 name : 'Tippy' ,
2626 format,
2727 file,
2828 sourcemap : true ,
2929 globals : {
30+ 'tippy.js' : 'tippy' ,
3031 react : 'React' ,
31- 'prop-types ' : 'PropTypes ' ,
32- 'tippy.js ' : 'tippy '
32+ 'react-dom ' : 'ReactDOM ' ,
33+ 'prop-types ' : 'PropTypes '
3334 }
3435} )
3536
Original file line number Diff line number Diff line change 1616 },
1717 "dependencies" : {
1818 "prop-types" : " ^15.6.2" ,
19- "tippy.js" : " ^3.0.0-beta.0 "
19+ "tippy.js" : " ^3.0.0-beta.1 "
2020 },
2121 "peerDependencies" : {
22- "react" : " >= 16.3"
22+ "react" : " >=16.3" ,
23+ "react-dom" : " >=16.3"
2324 },
2425 "devDependencies" : {
2526 "babel-jest" : " ^23.4.2" ,
2829 "babel-plugin-transform-object-rest-spread" : " ^6.26.0" ,
2930 "babel-preset-env" : " ^1.7.0" ,
3031 "babel-preset-react" : " ^6.24.1" ,
31- "enzyme" : " ^3.4.3 " ,
32- "enzyme-adapter-react-16" : " ^1.2.0 " ,
32+ "enzyme" : " ^3.5.0 " ,
33+ "enzyme-adapter-react-16" : " ^1.3.1 " ,
3334 "jest" : " ^23.5.0" ,
3435 "parcel" : " ^1.9.7" ,
36+ "react" : " ^16.4.2" ,
3537 "react-dom" : " ^16.4.2" ,
3638 "rollup" : " ^0.64.1" ,
3739 "rollup-plugin-babel" : " ^3.0.7" ,
You can’t perform that action at this time.
0 commit comments