Skip to content

Commit

Permalink
refactor: Remove UNSAFE_ react lifecycle hooks (#2196)
Browse files Browse the repository at this point in the history
* Remove UNSAFE_componentWillReceiveProps from CollectionSubtree

We don't need to copy the root prop into state. If we don't, there is no
need to update the state.

* Remove UNSAFE_componentWillReceiveProps from ElementsTableSampleEntries

* Remove UNSAFE_componentWillReceiveProps from ToolbarTemplateCreator

* Remove unnecessary UNSAFE_componentWillMount from ReactQuill

* Remove UNSAFE_ react life cycle hooks from QuillEditor

* Update deprecated componentWillReceiveProps in MetadataContainer

* Remove UNSAFE_componentWillUpdate from SectionSpectrum

The component already contains a `componentDidUpdate` method that also
calls `this.updateThumbNails`.

* Remove UNSAFE_componentWillReceiveProps in ContainerComponent

* Remove UNSAFE_componentWillReceiveProps in SampleComputedProps

* Remove UNSAFE_componentWillReceiveProps from EditableTable

* Remove UNSAFE_componentWillReceiveProps from LineChartContainer

Also update component to use createRef instead of ReactDOM.findDOMNode.

* Remove UNSAFE_componentWillReceiveProps from EditableCell

* Remove UNSAFE_componentWillReceiveProps from QuillViewer

* Remove UNSAFE_componentWillReceiveProps from NmrSimTab

* Remove UNSAFE_componentWillReceiveProps from ComputedPropsGraphContainer

* Remove UNSAFE_componentWillReceiveProps from WellplateDetails

* Remove UNSAFE_componentWillReceiveProps from WellplateDetailsContainers

* Remove obsolete UNSAFE_componentWillReceiveProps from WellContainer

The hideOverlay() does not exist and is not passed to the component
anymore.

* Remove UNSAFE_componentWillReceiveProps from LineChartWrapper

* Remove UNSAFE_componentWillReceiveProps from SampleDetails

* Remove UNSAFE_componentWillReceiveProps from SampleForm

* Remove UNSAFE_componentWillReceiveProps from NumeralInput

* Fix ResearchPlanMetadata form

With this change updating array values has been fixed by correctly
returning a new state in the `setState` handler.

This change also removes researchPlan from state, because changes are
only affected by its metadata.

We also clean up state management by removing all `ref` for state
updates in favour of proper `setState` calls using `handleFieldChange`.

Lastly, this also updates the UNSAFE_componentWillReceiveProps life cycle hook
to componentDidUpdate.

* Remove UNSAFE_componentWillReceiveProps from NumeralInputWithUnitsCompo

* Update state management in admin/textTemplates

This patch separates state management from presentational components and
gets rid of UNSAFE_componentWillReceiveProps.

* Remove UNSAFE_componentWillReceiveProps from ScreenDetailsContainers

* Remove UNSAFE_componentWillReceiveProps from EmbeddedResearchPlanDetails

* Remove UNSAFE_componentWillReceiveProps from ScreenDetails

* Remove UNSAFE_componentWillReceiveProps from ResearchPlanDetails

* Remove temperature from state in ReactionDetailsMainProperties

We don't ever modify the prop so we don't need to store it in state and
thus don't need to keep props and state in sync.

* Remove UNSAFE_componentWillReceiveProps from ReactionDetails

* Remove reaction from state in ReactionDetailsScheme

We were never updating the reaction state so we can simply use the prop
value and don't have to worry about keeping state and props in sync.

* Remove reaction from state in ReactionDetailsContainers

This removes reaction from state so we don't have to handle keeping
props and state in sync.

We are however still just mutating the variable instead of creating new
instances and passing those to our callbacks and handlers, but that is
for another time.

* Lazily calculate reaction duration display

This way we don't have to worry about when we need to calculate the
display values and can get rid of the life cycle methods that modified
the reaction prop.
  • Loading branch information
maiwald authored Oct 30, 2024
1 parent d3a4b87 commit c85856e
Show file tree
Hide file tree
Showing 40 changed files with 730 additions and 834 deletions.
303 changes: 0 additions & 303 deletions app/packs/src/apps/admin/textTemplates/TextTemplate.js

This file was deleted.

Loading

0 comments on commit c85856e

Please sign in to comment.