
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
Simple middleware of PJAX implementation with ReactJS
##Semantics
This module provides a solution for how to use PJAX with ReactJS, when a request with custom PJAX header is received, only state will be returned for partial update without server-side rendered markup. If it is not a PJAX request, markup and state will be returned together.
$ npm install react-pjax
var reactPjax = require('react-pjax');
Create a new middleware with the options as follow.
The module accepts these properties in the options object.
The header name to identify whether it is a PJAX request. Default is 'X-REACT-PJAX'.
The property name of state in the returned object inside res.send() and res.render(). Default is 'reactState'.
The property name of markup in the returned object inside res.send() and res.render(). Default is 'reactState'.
There are currently two methods, res.pjaxJson and res.pjaxRender.
It returns a JSON.
React element. It is defined by var MyReactElement = React.createFactory(require('MyReactComponent'));
React state in JSON format. It is used in server side rendering (SSR). e.g. React.renderToString(MyReactElement(reactState));
Meta is an object with properties. (e.g. title)
Render your view with passing markup and state, sends the rendered HTML to client side.
Name of view.
var reactPjax = require('react-pjax');
var express = require('express')
var app = express();
app.use(reactPjax({
reqHeader: 'using-pjax',
reactStateTag: 'myReactState',
reactMarkupTag: 'myReactMarkup'
}));
/**
* or using default setting
*
* app.use(reactPjax());
*/
var MyReactElement = React.createFactory(require('MyReactComponent'));
app.get('/', function(req, res) {
res.pjaxRender('index', MyReactElement, myReactState, {
title: 'home'
});
});
app.get('/json', function(req, res) {
res.pjaxJson(MyReactElement, myReactState, {
foo: 'bar'
});
});
View (index.dust)
{>"layouts/master" /}
{body}
{markup|s}
<script type="application/json" id="reactState">{reactState|s}</script>
{/body}
reactState is the reactStateTag and markup is the reactMarkupTag.
Copyright (C) 2015 Tony Ngan, released under the MIT License.
FAQs
PJAX implementation with ReactJS
We found that react-pjax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.