@@ -37,8 +37,10 @@ const Popper: React.FunctionComponent<PopperProps> = props => {
3737
3838 const popperRef = React . useRef < PopperJS > ( )
3939 const contentRef = React . useRef < HTMLElement > ( null )
40- const latestPlacement = React . useRef < PopperJS . Placement > ( )
41- const [ computedPlacement , setComputedPlacement ] = React . useState < PopperJS . Placement > ( )
40+ const latestPlacement = React . useRef < PopperJS . Placement > ( proposedPlacement )
41+ const [ computedPlacement , setComputedPlacement ] = React . useState < PopperJS . Placement > (
42+ proposedPlacement ,
43+ )
4244
4345 const computedModifiers : PopperJS . Modifiers = React . useMemo (
4446 ( ) =>
@@ -49,32 +51,18 @@ const Popper: React.FunctionComponent<PopperProps> = props => {
4951 [ rtl , offset , position ] ,
5052 )
5153
52- const scheduleUpdate = React . useCallback (
53- ( ) => {
54- if ( popperRef . current ) {
55- popperRef . current . scheduleUpdate ( )
56- }
57- } ,
58- [ popperRef . current ] ,
59- )
60-
61- const destroyInstance = React . useCallback (
62- ( ) => {
63- if ( popperRef . current ) {
64- popperRef . current . destroy ( )
65- popperRef . current = null
66- }
67- } ,
68- [ popperRef . current ] ,
69- )
54+ const scheduleUpdate = React . useCallback ( ( ) => {
55+ if ( popperRef . current ) {
56+ popperRef . current . scheduleUpdate ( )
57+ }
58+ } , [ ] )
7059
71- const instanceDependencies = [
72- computedModifiers ,
73- enabled ,
74- userModifiers ,
75- positionFixed ,
76- proposedPlacement ,
77- ]
60+ const destroyInstance = React . useCallback ( ( ) => {
61+ if ( popperRef . current ) {
62+ popperRef . current . destroy ( )
63+ popperRef . current = null
64+ }
65+ } , [ ] )
7866
7967 const createInstance = React . useCallback (
8068 ( ) => {
@@ -131,15 +119,15 @@ const Popper: React.FunctionComponent<PopperProps> = props => {
131119
132120 popperRef . current = createPopper ( targetRef . current , contentRef . current , options )
133121 } ,
134- [ targetRef . current , contentRef . current , ... instanceDependencies ] ,
122+ [ computedModifiers , enabled , userModifiers , positionFixed , proposedPlacement ] ,
135123 )
136124
137125 React . useEffect (
138126 ( ) => {
139127 createInstance ( )
140128 return destroyInstance
141129 } ,
142- [ computedModifiers , enabled , userModifiers , positionFixed , proposedPlacement ] ,
130+ [ createInstance ] ,
143131 )
144132
145133 React . useEffect ( scheduleUpdate , [ ...positioningDependencies , computedPlacement ] )
0 commit comments