Comments (5)
Yes, that it definitely a bug (and yes, that is kind of a dark corner both of Reagent and React...).
My (admittedly rather ugly) code tries to work around that React's controlled components don't like asynchronous rendering. Inputs with an onChange
handler only allow changes when that handler runs (that code in React seems to have moved here: https://github.com/facebook/react/blob/master/src/browser/dom/components/ReactDOMInput.js - see in particular the shouldComponentUpdate
method).
I'll have a think about what's going wrong as well.
And if you want look for a fix: the easiest way to run the tests, and play with the code in general, is to run "make runtest" in the top-level directory. That builds the entire demo-site, and runs tests both in browser and node. Probably doesn't work on windows, where something like lein with-profile test,dev cljsbuild auto client
may be required.
from reagent.
I think I've found an acceptable solution, in e539069
For "controlled components", Reagent now sets the value of inputs directly, rather than going through React, and schedules a forceUpdate
whenever on-change
is run, so that the value of the input is reset to its original value unless on-change leads to an update of the :value
property.
That way, the value of the input field and the underlying atom should always be kept in sync.
from reagent.
Thanks @holmsand! The fix is a little more complicated than I expected, but it makes sense. Looking forward to testing it in your next release.
from reagent.
Yes, it was a little more complicated than I expected too at first :)
Btw (and sorry if this is blindingly obvious to you), if you want to test it right now, you can just do lein install
in the Reagent directory, and then change your dependency on Reagent in your project.clj to [reagent "0.4.2-SNAPSHOT"]
.
from reagent.
Works great! Thanks for the tips - still new to clojure and lein.
from reagent.
Related Issues (20)
- Infinite loop in the reagent.impl.input wrapper HOT 1
- Reaction value propagation glitch - the dirty flag is not set HOT 3
- Bad react key warning when using false as key
- examples/material-ui not work HOT 1
- examples/material-ui not work HOT 1
- Docs on โChanged?โ inaccurate? HOT 5
- React 18 does not live reload with Shadow-CLJS in non-trivial projects HOT 5
- Prop types
- `TypeError` when using function components with `r/create-class` with `dom.server/render-to-string`
- ReactDOM.render is no longer supported in React 18. Use createRoot instead. HOT 2
- shadow-cljs emits a warning when using with-let HOT 4
- Korean input broken on :input and :textarea HOT 1
- Update docs? HOT 1
- MUI ThemeProvider not working HOT 1
- @@ -62,6 +62,45 @@ class _Config { } } // eslint-disable-next-line valid-jsdoc /** * fetch problem title, level via solved.ac api * @see {@link https://solvedac.github.io/unofficial-documentation/#/operations/getProblemByIdArray} * @param {string[]} pids - list of problem id (up to 100) * @param { ({ problemId, titleKo, level }) => void } callback */ function fetchProblemsFromSolvedAc(pids, callback) { const query = encodeURIComponent(pids.join(',')); console.log(`https://solved.ac/api/v3/problem/lookup?problemIds=${query}`); fetch(`https://solved.ac/api/v3/problem/lookup?problemIds=${query}`) .then((res) => { console.log('fetchProblemsFromSolvedAc', res); return res; }) .then((res) => res.json()) .then(callback) .catch(() => callback(null)); }
- Readme says npm i or add deps to .edn but (in my case at least) needed both HOT 1
- Any interest in being able to replace `react/createElement` with a custom function? HOT 7
- The cursor disappears at the end of a controlled input on Chrome
- Reusable components following HTML semantics of Opional Attributes and Variadic Children HOT 3
- Controlled input loses cursor under ShadowRoot in React 18 HOT 3
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 reagent.