rrutsche / react-parallax

A React Component for parallax effect
MIT License
855 stars 76 forks source link

Basic state update broken (or late) for child elements #67

Closed kaleabmelkie closed 4 years ago

kaleabmelkie commented 4 years ago

Bug

I have a simple controlled <input> as a child of a <Parallax>. The state update for the input is broken.

Characters have to be entered twice and the only the previous ones appear (i.e. it's late by one entry). And if the new character is the same as the previous one, it behaves even more weirdly.

import React, { useState } from 'react'
import { Parallax } from 'react-parallax'

function App() {
  const [val, setVal] = useState('')

  return (
    <Parallax>
      <input value={val} onChange={e => setVal(e.target.value)} />
    </Parallax>
  )
}

I'm using the v3.0.0.

rrutsche commented 4 years ago

That is due to a recent change from componentWillReceiveProps to componentDidUpdate I think. Have a solution in mind and will fix it soon.