Library for managment of application states and more
npm install jumper_reactin component file:
``javascript
import React, { Component } from 'react';
import { ActionsStack } from 'jumper_react/appState';
export default class SampleComponent extends Component {
constructor(props) {
super(props);
let self = this;
this.state = {
currentMenu:""
}
this.actions = new ActionsStack(this, [
SampleAction1,
SampleAction2
], { loadResumeable:false });
let lastData = this.actions.restoreComponentProp("exampleData");
this.actions.addEventListener("beforeunload", function() {
this.saveComponentProp("exampleData");
});
}
componentDidMount() {
this.actions.restoreStacksSessions();
}
render() {
return (<>
in operations/actions file:
`javascript
import { ActionOperation, ActionResumeOperation, TemponaryActionOperation } from 'jumper_react/appState';export class SampleTemponaryAction1 extends TemponaryActionOperation {
}
export class SampleAction1 extends ActionOperation {
onStore(component, inputData) {
component.currDocument.dimensionX += inputData.count;
return { };
}
}
export class SampleAction2 extends ActionOperation {
onStore(component, inputData) {
component.currDocument.dimensionY += inputData.count;
return { };
}
}
`Important functions
$3
1. htmlStr: string - input with sample HTML code to parse
2. allowedTags: Array = [] - Array of allowed or dissalowed tags (string tag name) to parse
3. allowed: boolean - if true all tag names given in argument 2 will be parsed, otherwise ignored.
https://codesandbox.io/s/jumper-module-react-simple-parser-3b8c9 `javascript
import React from "react";
import "./styles.css";
import { parseHTMLReactComponent } from "jumper_react/components";export default function App() {
return parseHTMLReactComponent(
'
Hello world!
Really? Yolo I love react!
',
["h1"],
false
);
}
`$3
1. htmlStr: string - input with sample HTML code to parse
2. allowedTags: Array = [] - Array of allowed or dissalowed tags (string tag name) to parse
3. allowed: boolean - if true all tag names given in argument 2 will be parsed, otherwise ignored. `javascript
import { parseHTMLComponent } from "jumper_react/components";
let container = document.createElement("div"), childs = parseHTMLComponent(
'Hello world!
Really? Yolo I love react!
',
["h1"],
false
);
for(let el of childs) container.appendChild(el);
console.log(container);
document.body.innerHTML = "";
document.body.appendChild(container);
`$3
1. targetStr: string - input with sample text to parse
2. initialObj: any - can be an Array or Object.prototype. Contains a elements to replace.
Types:
* %s - String
* %f - float
* %a - any
* %ad - auto detect
* %d - decimal
* %n - science notation
* %oct - octal number
* %hex - hex number
* %bin - binary number
* %f{number} - floating with rounding (experimental)
* %b - boolean
* %bt - boolean translated (experimental) `javascript
console.log(format("Hello %s exacly! Wow, we make it %d times!", ["World", 14]));
console.log(format("Thats really simple with %s[labelsWord], you can use it in any %s[situationWord]!", {labelsWord:"labels", situationWord:"situation"}));
``