question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'key' of null on Razzle JS

See original GitHub issue

I’ve created an NPM package to be shared across my projects and installed it successfully in a standard CRA App, it renders, the styles and everything is great.

However, when using it with Razzle JS, which is a SSR implementation I keep on getting:

TypeError: Cannot read property ‘key’ of null

I was able to trace the issue to:

image

I would expect emotion to work out of the box with both my SSR and non CRA project, however that doesn’t seem to be the case.

I’ve tried with the latest version of Emotion, and React, and have been trying to go back a bit, still, nothing is happening.

Here is an extract of what my package.json looks like:

{
    "name": "@drewberryuk/common-react-components",
    "version": "1.0.1h",
    "description": "Put a description here",
    "main": "build/index.js",
    "repository": {
        "type": "git",
        "url": "git+ssh://git@bitbucket.org/drewberry/common-react-components.git"
    },
    "homepage": "https://bitbucket.org/drewberry/common-react-components#readme",
    "author": {
        "name": "Drewberry",
        "email": "support@drewberry.co.uk"
    },
    "peerDependencies": {
        "react": "^16.9.0"
    },
    "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "start": "webpack --watch",
        "build": "webpack"
    },
    "dependencies": {
        "@babel/core": "^7.2.2",
        "@babel/plugin-proposal-class-properties": "^7.2.3",
        "@babel/plugin-transform-react-jsx": "^7.3.0",
        "@babel/preset-env": "^7.6.2",
        "@babel/preset-react": "^7.0.0",
        "@babel/runtime": "^7.4.4",
        "@emotion/babel-preset-css-prop": "^10.0.17",
        "@emotion/cache": "^10.0.9",
        "@emotion/core": "^10.0.9",
        "@emotion/css": "^10.0.9",
        "babel-loader": "^8.0.0",
        "babel-plugin-transform-object-rest-spread": "^6.26.0",
        "react": "^16.9.0",
        "react-router-dom": "^5.0.1",
        "webpack": "4.39.1",
        "webpack-cli": "^3.3.9"
    }
}


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Dec 12, 2019

Actually you should just not bundle your dependencies in - let them stay as your dependencies (and thus in other node_modules of your consumers). Then each tool (like Next) should be able to resolve correctly to appropriate files - because it will use the file structure (or rather mostly package.json metadata) prepared by us (or other packages using this technique).

0reactions
Andaristcommented, Dec 15, 2019

No problem, glad that you have figured it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getting error "TypeError: Cannot read properties of null ...
So I'm trying to use useState in my react app, but as soon as I add in the line of code to initialize...
Read more >
Cannot read property 'medium' of null" Cant figure it out! - Reddit
I keep getting a "TypeError: Cannot read property 'medium' of null" particular in my second component that contains an img key from an...
Read more >
typeerror can not read property x of null - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >
Cannot read properties of null (reading 'contains')error in react ...
TypeError: Cannot read properties of null (reading 'contains'), Need useEffect Cleanup,EventBubblingtypeerror cannot read property of null ...
Read more >
Localized Server-Side Rendering with React | Phrase
This is Razzle's client.js untouched. It uses ReactDOM's hydrate() , rather than render() , since we want React to simply connect JavaScript ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found