Skip to content
Advertisement

Tag: reactjs

Get viewport/window height in ReactJS

How do I get the viewport height in ReactJS? In normal JavaScript I use but using ReactJS, I’m not sure how to get this information. My understanding is that only works for components created. However this is not the case for the document or body element, which could give me height of the window. Answer Set the props viewport height

ReactJS – prevent re-render children

I have parent React component with 3 children, like this: I am trying to be able to change children’s position based on current parent state. So in different cases I need to return C1,C3,C2 or C3,C2,C1, etc. But I want to this without re-render the children. I am trying to use shouldComponentUpdate on each of the children but its gets

ReactJS: setTimeout() not working?

Having this code in mind: Isn’t the state supposed to change only after 3 seconds? It’s changing immediately. My main goal here is to change the state every 3 seconds (with setInterval()), but since it was not working, I tried setTimeout(), which is not working either. Any lights on this? Thanks! Answer Do Otherwise, you are passing the result of

How to pass nested properties with spread attributes correctly? (JSX)

#1 Hello. I have the code: Why do I get 1 variable reference for 2 separate components instead of 2 instances of nested.prop for every component? Why this.props saves only last setted value for all instances of the component after mounting? Is it a normal behavior? I think the correct behavior is having different property values for different instances. P.S.

Webpack-dev-server not bundling even after showing bundle valid message

I’ve set up a basic react application with webpack but I couldn’t get the webpack-dev-server running properly. I’ve installed webpack-dev-server globally and tried running the command sudo webpack-dev-server –hot as hot reloading was required. The project seems to be working fine with just webpack cmd. It builds into my build folder and I can get it working via some server

Reactjs: how to share a websocket between components

I’m new to React and I’m having some issues regarding components structure and sharing a websocket between them. The app consists of categories and products. The initial data load will be done with an Ajax request and a websocket will be used keep data updated. My component hierarchy looks like this: CategoriesList Category ProductsList Product CategoriesList holds the state of

react-router: How to disable a , if its active?

How can I disable a <Link> in react-router, if its URL already active? E.g. if my URL wouldn’t change on a click on <Link> I want to prevent clicking at all or render a <span> instead of a <Link>. The only solution which comes to my mind is using activeClassName (or activeStyle) and setting pointer-events: none;, but I’d rather like

React intellisense in Visual Studio Code

I’m sure I’m missing something simple, but I simply can’t get React.js IntelliSense to work in Visual Studio code. I have done the following: npm install typings ext install Typings Installer in Visual Studio Code ext install Typings in Visual Studio Code typings init in the root directory of my “app” typings install –ambient react-global in the root of my

Accessing Redux Store from routes set up via React Router

I would like to make use of react-router’s onEnter handler in order to prompt users to authenticate when entering a restricted route. So far my routes.js file looks something like this: Ideally, I’d like my requireAuth function to be a redux action that has access to the store and current state, that works like this: store.dispatch(requireAuth()). Unfortunately I don’t have

Advertisement