Comments (5)
It looks like the issue is here:
RenderOne
https://github.com/grammarly/focal/blob/master/src/react/react.ts#L388-L389RenderMany
https://github.com/grammarly/focal/blob/master/src/react/react.ts#L487-L488
According to the documentation (https://reactjs.org/docs/react-component.html#setstate):
Think of setState() as a request rather than an immediate command to update the component.
liftedComponent.setState()
doesn't update liftedComponent.state
immediately.
So, every new renderCache
is compared to the initial value, and if they are equal, the state isn't updated.
from focal.
A possible solution is moving structEq(liftedComponent.state.renderCache, renderCache)
to shouldComponentUpdate
(https://github.com/grammarly/focal/blob/master/src/react/react.ts#L116).
However, I'm not sure about the performance here.
@blacktaxi what do you think?
from focal.
That seems to be a good catch! Let me take some time to debug this. Not sure about moving structEq
to shouldComponentUpdate
, intuitively it indeed seems to ought to affect performance.
Another obvious solution could be to use the this.setState(prevState => ...)
overload and perform the structEq
call in the callback.
from focal.
@blacktaxi this.setState(prevState => prevState)
triggers render. It looks like it doesn't make sense to use structEq
here. Code - https://codesandbox.io/s/0ol9q3q38w
from focal.
Added a repro and tracking this in #27 now
from focal.
Related Issues (20)
- Set state in state.subscribe() HOT 6
- How to integrate third-party React components? HOT 3
- No "empty observable" warning when using a single empty Observable prop HOT 2
- Fix `instanceof Observable` check HOT 1
- Problem with .view and unsubscribe HOT 1
- [Questions] React Ecosystem Support: CRA & React Native? HOT 15
- Replace regex in Lens.prop with Proxy HOT 2
- Can't build a project HOT 2
- Typescript error with strictNullChecks HOT 3
- React hooks HOT 5
- Any CRUD example?
- Uncaught TypeError: f.a.key is not a function HOT 4
- Publish Atom/Lens-only version HOT 5
- Classes in Atoms lose their functions after modification
- Do not log on production HOT 1
- Persistence
- Support for React 17 HOT 2
- Property 'lens' does not exist on type 'ReadOnlyAtom<State>' HOT 1
- yarn audit reports malware HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from focal.