File tree 8 files changed +157
-0
lines changed
8 files changed +157
-0
lines changed Original file line number Diff line number Diff line change
1
+ /node_modules
2
+
3
+ npm-debug.log *
4
+ yarn-debug.log *
5
+ yarn-error.log *
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " react-nullable-transition-master" ,
3
+ "version" : " 1.0.0" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "build" : " rm -rf package/dist && tsc -p package/tsconfig.json"
8
+ },
9
+ "keywords" : [],
10
+ "author" : " " ,
11
+ "license" : " ISC" ,
12
+ "devDependencies" : {
13
+ "typescript" : " ^3.8.3"
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ /node_modules
2
+
3
+ npm-debug.log *
4
+ yarn-debug.log *
5
+ yarn-error.log *
6
+
7
+ /dist
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " react-nullable-transition" ,
3
+ "version" : " 1.0.2" ,
4
+ "description" : " " ,
5
+ "main" : " dist/index.js" ,
6
+ "module" : " ./dist/index.js" ,
7
+ "types" : " ./dist/index.d.ts" ,
8
+ "keywords" : [
9
+ " animation" ,
10
+ " transition" ,
11
+ " react-transition" ,
12
+ " react-transition-group"
13
+ ],
14
+ "license" : " MIT" ,
15
+ "peerDependencies" : {
16
+ "react" : " >=16.12" ,
17
+ "react-transition-group" : " >=4.3"
18
+ },
19
+ "devDependencies" : {
20
+ "@types/react" : " ^16.9.31" ,
21
+ "@types/react-dom" : " ^16.9.6" ,
22
+ "@types/react-transition-group" : " ^4.2.4"
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ import React , { useEffect , useState } from 'react' ;
2
+ import { CSSTransition } from 'react-transition-group' ;
3
+
4
+ type Props = Exclude < Exclude < React . ComponentProps < typeof CSSTransition > , 'in' > , 'appear' > & {
5
+ className ?: string ;
6
+ }
7
+
8
+ export const TransitionNullable : React . FC < Props > = ( { className, children, ...props } ) => {
9
+ const [ childrenCopy , setChildrenCopy ] = useState < typeof children > ( null ) ;
10
+ const persistentChildren : typeof children = children || childrenCopy ;
11
+
12
+ useEffect ( ( ) => {
13
+ if ( children ) {
14
+ setChildrenCopy ( children ) ;
15
+ }
16
+ } , [ children ] ) ;
17
+
18
+ function handleExited ( el : HTMLElement ) {
19
+ props . onExited && props . onExited ( el ) ;
20
+
21
+ setChildrenCopy ( null ) ;
22
+ }
23
+
24
+ if ( persistentChildren ) {
25
+ return (
26
+ < CSSTransition { ...props } appear in = { Boolean ( children ) } onExited = { handleExited } >
27
+ { persistentChildren }
28
+ </ CSSTransition >
29
+ ) ;
30
+ }
31
+
32
+ return null ;
33
+ } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "target" : " esnext" ,
4
+ "module" : " esnext" ,
5
+ "strict" : true ,
6
+ "jsx" : " react" ,
7
+ "importHelpers" : true ,
8
+ "moduleResolution" : " node" ,
9
+ "experimentalDecorators" : true ,
10
+ "esModuleInterop" : true ,
11
+ "allowSyntheticDefaultImports" : true ,
12
+ "resolveJsonModule" : true ,
13
+ "sourceMap" : true ,
14
+ "isolatedModules" : true ,
15
+ "declaration" : true ,
16
+ "outDir" : " ./dist" ,
17
+ "lib" : [
18
+ " dom" ,
19
+ " es2017" ,
20
+ ],
21
+ "typeRoots" : [ " ./node_modules/@types" ]
22
+ },
23
+ "include" : [
24
+ " src/**/*.ts" ,
25
+ " src/**/*.tsx"
26
+ ],
27
+ "exclude" : [
28
+ " node_modules"
29
+ ]
30
+ }
Original file line number Diff line number Diff line change
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ " @types/prop-types@* " :
6
+ version "15.7.3"
7
+ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
8
+ integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
9
+
10
+ " @types/react-dom@^16.9.6 " :
11
+ version "16.9.6"
12
+ resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.9.6.tgz#9e7f83d90566521cc2083be2277c6712dcaf754c"
13
+ integrity sha512-S6ihtlPMDotrlCJE9ST1fRmYrQNNwfgL61UB4I1W7M6kPulUKx9fXAleW5zpdIjUQ4fTaaog8uERezjsGUj9HQ==
14
+ dependencies :
15
+ " @types/react" " *"
16
+
17
+ " @types/react-transition-group@^4.2.4 " :
18
+ version "4.2.4"
19
+ resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.2.4.tgz#c7416225987ccdb719262766c1483da8f826838d"
20
+ integrity sha512-8DMUaDqh0S70TjkqU0DxOu80tFUiiaS9rxkWip/nb7gtvAsbqOXm02UCmR8zdcjWujgeYPiPNTVpVpKzUDotwA==
21
+ dependencies :
22
+ " @types/react" " *"
23
+
24
+ " @types/react@*" , "@types/react@^16.9.31":
25
+ version "16.9.31"
26
+ resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.31.tgz#6a543529766c8934ec8a89667376c2e73e9e2636"
27
+ integrity sha512-NpYJpNMWScFXtx3A2BJMeew2G3+9SEslVWMdxNJ6DLvxIuxWjY1bizK9q5Y1ujhln31vtjmhjOAYDr9Xx3k9FQ==
28
+ dependencies :
29
+ " @types/prop-types" " *"
30
+ csstype "^2.2.0"
31
+
32
+ csstype@^2.2.0 :
33
+ version "2.6.10"
34
+ resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
35
+ integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==
Original file line number Diff line number Diff line change
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
5
+ typescript@^3.8.3 :
6
+ version "3.8.3"
7
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
8
+ integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
You can’t perform that action at this time.
0 commit comments