Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# `react-mathjax`
#### (updated with React 15.6.1)

[![NPM version](https://badge.fury.io/js/react-mathjax.svg)](http://badge.fury.io/js/react-mathjax)

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
"devDependencies": {
"babelify": "^7.3.0",
"browserify": "^13.1.1",
"create-react-class": "^15.6.0",
"eslint": "^3.12.0",
"eslint-config-gitbook": "^1.4.0",
"gh-pages": "^0.12.0",
"http-server": "^0.9.0",
"react": "^15.4.1",
"react-dom": "^15.4.1"
"prop-types": "^15.5.10",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"dependencies": {
"babel-cli": "^6.18.0",
Expand Down
32 changes: 18 additions & 14 deletions src/context.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* global MathJax */
const React = require('react');
const createReactClass = require('create-react-class');
const PropTypes = require('prop-types');
const loadScript = require('load-script');

const DEFAULT_SCRIPT =
Expand All @@ -17,20 +19,8 @@ const DEFAULT_OPTIONS = {
* Context for loading mathjax
* @type {[type]}
*/
const MathJaxContext = React.createClass({
propTypes: {
children: React.PropTypes.node.isRequired,
script: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.oneOf([false])
]),
options: React.PropTypes.object
},

childContextTypes: {
MathJax: React.PropTypes.object
},

const MathJaxContext = createReactClass({

getDefaultProps() {
return {
script: DEFAULT_SCRIPT,
Expand Down Expand Up @@ -75,4 +65,18 @@ const MathJaxContext = React.createClass({
}
});


MathJaxContext.propTypes = {
children: PropTypes.node.isRequired,
script: PropTypes.oneOfType([
PropTypes.string,
PropTypes.oneOf([false])
]),
options: PropTypes.object
};

MathJaxContext.childContextTypes = {
MathJax: PropTypes.object
};

module.exports = MathJaxContext;
26 changes: 15 additions & 11 deletions src/node.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
const React = require('react');
const createReactClass = require('create-react-class');
const PropTypes = require('prop-types');
const process = require('./process');

/**
* React component to render maths using mathjax
* @type {ReactClass}
*/
const MathJaxNode = React.createClass({
propTypes: {
inline: React.PropTypes.bool,
children: React.PropTypes.node.isRequired,
onRender: React.PropTypes.func
},

contextTypes: {
MathJax: React.PropTypes.object
},

const MathJaxNode = createReactClass({

getDefaultProps() {
return {
inline: false,
Expand Down Expand Up @@ -137,4 +130,15 @@ const MathJaxNode = React.createClass({
}
});


MathJaxNode.propTypes = {
inline: PropTypes.bool,
children: PropTypes.node.isRequired,
onRender: PropTypes.func
};

MathJaxNode.contextTypes = {
MathJax: PropTypes.object
};

module.exports = MathJaxNode;