New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@midudev/react-static-content

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@midudev/react-static-content - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

src/index.js

21

dist/index.js
import React, { useEffect, useRef, useState } from 'react';
export default function StaticContent({
children
}) {
const ref = useRef(null);
const [render, setRender] = useState(typeof window === 'undefined');
export default function StaticContent(_ref) {
var children = _ref.children;
var ref = useRef(null);
var _useState = useState(typeof window === 'undefined'),
render = _useState[0],
setRender = _useState[1];
useEffect(function () {
// check if the innerHTML is empty as client side navigation
// need to render the component without server-side backup
const isEmpty = ref.current.innerHTML === '';
var isEmpty = ref.current.innerHTML === '';

@@ -18,7 +21,7 @@ if (isEmpty) {

if (render) {
return React.createElement("div", null, children);
return /*#__PURE__*/React.createElement("div", null, children);
} // avoid re-render on the client
return React.createElement("div", {
return /*#__PURE__*/React.createElement("div", {
ref: ref,

@@ -30,2 +33,2 @@ suppressHydrationWarning: true,

});
}
}
{
"name": "@midudev/react-static-content",
"version": "1.0.3",
"version": "1.0.4",
"description": "Server Side Rendering for a component and skip the hydration step on the client. Useful for components that don't need to use interactivity (like SEO links).",

@@ -11,3 +11,4 @@ "main": "dist/index.js",

"scripts": {
"prepare": "dwp=$(pwd) && ../../node_modules/.bin/babel $dwp/index.js --out-file $dwp/dist/index.js --presets=@babel/react",
"prepare": "../../node_modules/.bin/babel src -d dist --config-file ../../babel.config.json",
"release": "../../node_modules/.bin/np",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -14,0 +15,0 @@ },

@@ -9,13 +9,13 @@ ## Static Content 📸

⚡ Avoid re-hydrate for static components
🤳 Thus could greatly improve TTI
- ⚡ Avoid re-hydrate for static components
- 🤳 Thus could greatly improve TTI
### Downsides... 👎
⚠️ Lose interactivity
🏋️‍ Hydration data still there
🥪 Element wrapper (ex. <div>)
- ⚠️ Lose interactivity
- 🏋️‍ Hydration data still there
- 🥪 Element wrapper (ex. <div>)
### Keep in mind... 🧠
📸 For expensive rendering lists or static content (SEO Footers)
🤖 GoogleBot is definitely going to detect it
- 📸 For expensive rendering lists or static content (SEO Footers)
- 🤖 GoogleBot is definitely going to detect it

@@ -22,0 +22,0 @@ ## How to use 👨‍🏫

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc