Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-cookie

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-cookie - npm Package Compare versions

Comparing version 0.1.1 to 0.1.7

9

index.js
var cookie = require('cookie');
var _cookies = cookie.parse((document && document.cookie) ? document.cookie : '');
var _cookies = cookie.parse((typeof document !== 'undefined') ? document.cookie : '');

@@ -18,6 +18,7 @@ for (var key in _cookies) {

function save(name, val, opt) {
_cookies[name] = val;
// Cookies only work in the browser
if (!document || !document.cookie) return;
_cookies[name] = val;
if (typeof document === 'undefined') return;
document.cookie = cookie.serialize(name, val, opt);

@@ -24,0 +25,0 @@ }

{
"name": "react-cookie",
"version": "0.1.1",
"version": "0.1.7",
"description": "Load and save cookies within your React application",
"main": "index.js",
"main": "dist/react-cookie.min.js",
"files": [

@@ -24,3 +24,3 @@ "index.js"

"scripts": {
"build": "browserify index.js > dist/react-cookie.js & uglifyjs dist/react-cookie.js -o dist/react-cookie.min.js"
"build": "mkdir dist & browserify index.js > dist/react-cookie.js & uglifyjs dist/react-cookie.js -o dist/react-cookie.min.js"
},

@@ -27,0 +27,0 @@ "dependencies": {

@@ -15,3 +15,3 @@ # react-cookie

export default class MyApp extends React.component {
export default class MyApp extends React.Component {

@@ -25,3 +25,3 @@ constructor(props) {

this.state.userId = userId;
cookie.save('userId', nextState.userId);
cookie.save('userId', userId);
}

@@ -51,3 +51,3 @@

this.state.userId = userId;
cookie.save('userId', nextState.userId);
cookie.save('userId', userId);
},

@@ -66,6 +66,11 @@

## Without CommonJS
You can use react-cookie with anything by using the global variable `reactCookie`.
*Note that `window` need to exists to use `reactCookie`.*
## Usage
### `reactCookie.load(name: string)`
### `reactCookie.save(name: string, val, [opt])`
### `reactCookie.load(name)`
### `reactCookie.save(name, val, [opt])`

@@ -72,0 +77,0 @@ ## opt

Sorry, the diff of this file is not supported yet

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