SHISME / react-native-draggable-grid

A draggable and sortable grid of react-native
321 stars 94 forks source link

Remove dependency on componentWillMount, componentWillReceiveProps #27

Closed frankcalise closed 4 years ago

frankcalise commented 4 years ago

Both lifecycle methods, componentWillMount and componentWillReceiveProps are being deprecated and will not be supported in React 17.

Warnings spit out now but will need to move to UNSAFE_X, where X is the method going forward. However, it would be best if could just move to componentDidMount and componentDidUpdate.

Any plans for fixing this?

See more details here: https://reactjs.org/blog/2018/03/29/react-v-16-3.html

SHISME commented 4 years ago

Yes, i had plan to use hook to restructure it.

SHISME commented 4 years ago

I had restructure it by hooks.

frankcalise commented 4 years ago

Unable to use ref now, see error below:

<DraggableGrid ref={grid => this.grid = grid} numColumns={3} renderItem={this.renderItem} data={this.state.photos} onDragRelease={this.onDragRelease} onDragStart={this.onDragStart} />

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s%s,

SHISME commented 4 years ago

Unable to use ref now, see error below:

<DraggableGrid ref={grid => this.grid = grid} numColumns={3} renderItem={this.renderItem} data={this.state.photos} onDragRelease={this.onDragRelease} onDragStart={this.onDragStart} />

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s%s,

I want to know why do you want to use ref?

frankcalise commented 4 years ago

My mistake, it was legacy code left in place by mistake (sorry, I just joined project using your library). Thanks for your help! Lifecycle warnings are gone.