How to declare a global variable in React?

Why don’t you try using Context? You can declare a global context variable in any of the parent components and this variable will be accessible across the component tree by this.context.varname. You only have to specify childContextTypes and getChildContext in the parent component and thereafter you can use/modify this from any component by just specifying contextTypes in the child component. However, please take … Read more

What does “isomorphic React” mean?

Isomorphic: “corresponding or similar in form or relations”. With regard to web apps, this means that the server is somehow similar to the client – in the sense that the server is capable of rendering as much as the client. In a way, isomorphic web apps are a return to the old paradigm where the … Read more

How to resolve “Cannot use import statement outside a module” in jest

Also using Babel, Typescript and Jest. Had the same failure, driving me crazy for hours. Ended up creating a new babel.config.js file specifically for the tests. Had a large .babelrc that wasn’t getting picked up by jest no matter what i did to it. Main app still uses the .babelrc as this overrides babel.config.js files. Install jest, ts-jest and babel-jest: babel.config.js (only used by … Read more

tech