@@ -115,6 +115,21 @@ class Space extends React.Component<AllProps, IState> {
115115 }
116116 }
117117
118+ public componentWillReceiveProps ( nextProps : AllProps ) {
119+ if ( this . props . size !== nextProps . size ||
120+ this . props . anchor !== nextProps . anchor ) {
121+ this . setState ( {
122+ parsedSize : typeof nextProps . size === "string" ? 0 : nextProps . size as number | undefined ,
123+ left : nextProps . anchor !== AnchorType . Right ? 0 : undefined ,
124+ top : nextProps . anchor !== AnchorType . Bottom ? 0 : undefined ,
125+ right : nextProps . anchor !== AnchorType . Left ? 0 : undefined ,
126+ bottom : nextProps . anchor !== AnchorType . Top ? 0 : undefined ,
127+ width : this . isHorizontalSpace ( ) ? nextProps . size || 0 : undefined ,
128+ height : this . isVerticalSpace ( ) ? nextProps . size || 0 : undefined
129+ } )
130+ }
131+ }
132+
118133 public componentWillUnmount ( ) {
119134 if ( this . props . trackSize ) {
120135 if ( this . resizeSensor ) {
@@ -298,10 +313,17 @@ class Space extends React.Component<AllProps, IState> {
298313 spaceTakers : this . state . spaceTakers ,
299314 registerSpaceTaker :
300315 ( spaceTaker : ISpaceTaker ) => {
301- if ( ! this . state . spaceTakers . find ( t => t . id === spaceTaker . id ) ) {
316+ const existing = this . state . spaceTakers . find ( t => t . id === spaceTaker . id ) ;
317+
318+ if ( ! existing ) {
302319 this . setState ( {
303320 spaceTakers : [ ...this . state . spaceTakers , spaceTaker ]
304321 } )
322+ } else {
323+ existing . adjustedSize = 0 ;
324+ existing . order = spaceTaker . order ;
325+ existing . anchorType = spaceTaker . anchorType ;
326+ existing . size = spaceTaker . size ;
305327 }
306328 } ,
307329 removeSpaceTaker :
0 commit comments