Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am learning React and wondered if there was a way to re-render on state change without using React. Is this possible in plain JavaScript?
Let's assume that our whole application is this:
<input id="myState" />
<h2 id="myView"></h2>
We have some sort of value we call state and we have some sort of value we call view. Now what we want is that when we update our state, we want to update our view. Yes, that is absolutely possible without React/Redux/etc.
window.onload = function(){
var state = document.getElementById('myState'),
view = document.getElementById('myView')
state.addEventListener('keyup',function(e){
view.innerText = e.target.value
})
}
Every time the 'state' of our application changes, we are resetting the 'view'.
Going past this dummy problem you will run into alot of issues, which are the issues that React/Angular/Ember/Backbone/etc all try to help fix.
Can it be done in vanilla JS? Yes, because someone else already did it in vanilla JS.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Since a year and a half I am trying to figure out how some websites update their content in real time without AJAX method.
Please see this example website: https://pro.btcturk.com/en/basic/exchange/BTC_TRY
That website is changing many texts within content in different timing.
It means that when the server is updated with new values in the database then the website is listening to database changes and then reflecting/delivering inside content without ajax calls.
Can someone give an example how to achieve such functionality possibly using Javascript or PHP normal hand-code appreciated?
Thank you
You can see the process here:
More information here: Websockets
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am having a hard time finding a good yet simple article on the 'behind the scenes' of jQuery. I know this is not simple though.
But does jQuery actually uses cycles and states like React does ? If not, what is it, in simple words ?
What is happening when jQuery does that ?
$('.netreviews_stats_stars_big').css('opacity', '0.2');
The DOM manipulation parts of jQuery do direct DOM manipulation. It doesn't take a data-driven approach like React so the idea of state in the React sense is meaningless.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have a ReactJS functional component that should update the class of an element within same component on a click event.
The question is really simple and I am probably overthinking it as performance-wise. Am I better of converting the functional component so that it manages state and I change class depending on the state? Or am I better of with changing class onClick with classList.add('active') ?
If anyone has any idea which would be better please let me know :)
If you need to change elements classes in relation with some internal state of the component (that you change with onClick handler), then you should go with stateful components (class components or use Hooks).
I strongly suggest you to avoid directly accessing DOM elements and manually add classes. React has it's own way to keep control of these things.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working on reactJS, Currently I have Image in one component and I want to send this image to another. Could you please help me how I can send this image to another component. If you give me example it would be better
Thanks
If this image needs to be accesible from different components, consider making it part of either a global configuration (if it's a fixed value), put in on the context, save it to localStorage, or save it in the store so it can be accessed from anywhere in the app.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Hi I am novice to Angularjs, I am having lot of factories in my application, the scenario is lets assume like obj1 in factoryA. At some point of time when I console.log(obj1) , then it shows multiple properties inside it. It is getting updated from other factories and controllers. Since it is big application I dont know the complete flow and it is very hard to find out. So, is there any way to track down history like from where and all the particular object in factory is invoked and updated ?.
Use the debugger keyword as breakpoints.
You shall be able to examine all values that are in the current scope.