https://github.com/sim51/stefi-graph
https://github.com/sim51/stefi-graph
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sim51/stefi-graph
- Owner: sim51
- Created: 2016-07-19T21:45:16.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-20T15:11:55.000Z (about 8 years ago)
- Last Synced: 2025-01-24T16:44:10.058Z (5 months ago)
- Language: JavaScript
- Size: 1.43 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
= Stefi Graph
Search, Transform, Explore, Fetch and Interact your graph database
== TODO
* Adding row result ...
* parameter query (don't forget widget on this !)
* refacto on neo4j service
* refacto on edit object
* refacto on action : make unitaries action
* adding label/type autocompletion on cypher
* settings : modify schema== React reminder
=== Property VS state
A react component can change its state, but not its properties.
* *properties* : for a top to bottom communication
* *state* : for an internal state of the component=== Component Skeleton
[code,javascript]
----
import React, {Component, PropTypes} from "react";/**
* Skeleton component
*/
class Skeleton extends Component {// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Initialization
// -----------------------
// * Constructor that initialize the state with props
// * ComponentWillMount
// * Render
// * ComponentDidMount
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/**
* Component constructor.
* It's where we set the component state with properties to initialize the state.
*
* @param props Properties passed to the component
*/
constructor(props) {
super(props);
this.state = {
count = props.count,
name = props.name
};
}/**
* This method is called before the render method is executed.
* It is important to note that setting the state in this phase will not trigger a re-rendering.
*/
componentWillMount() {}
/**
* This method returns the needed component markup.
*/
render() {return (
)
}/**
* As soon as the render method has been executed this method is called.
* So here the DOM can be accessed and you can do some DOM manipulations or data fetching operations.
* Any DOM interactions should always happen in this phase not inside the render method.
*/
componentDidMount() {}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// State change lifecycle
// -----------------------
// * Updating state
// * ShouldComponentUpdate
// * ComponentWillUpdate
// * Render
// * ComponentDidUpdate
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/**
* When state change, this method is called before the render method to define if a re-rendering is needed.
*
* @return Boolean
*/
shouldComponentUpdate(nextProps, nextState) {
return true;
}/**
* This method is called as soon as the the shouldComponentUpdate returned true.
* Any state changes via this.setState are not allowed as this method should be strictly used to prepare for an upcoming update not trigger an update itself.
*/
componentWillUpdate(nextProps, nextState) {}
/**
* This method is called after the render method. Similar to the componentDidMount.
* It can be used to perform DOM operations after the data has been updated.
*
* @param prevProps
* @param prevState
*/
componentDidUpdate(prevProps, prevState) {}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Properties change lifecycle
// ----------------------------
// * Updating Props
// * ComponentWillReceiveProps
// * ShouldComponentUpdate
// * ComponentWillUpdate
// * Render
// * ComponentDidUpdate
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/**
* This method is called when the props have changed and when this is not an initial rendering.
* It allow you to update the state depending on the existing and upcoming props, without triggering another rendering.
* @param nextProps
*/
componentWillReceiveProps(nextProps) {
this.setState({
// set something
});
}// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Unmouting
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/**
* This method is called before the component is removed from the DOM.
* It can be used when you need to perform clean up operations (ex: removing any timers defined in componentDidMount).
*/
componentWillUnmount() {
}/**
* This method is called when component is removed.
*/
componentDidMount() {
}
}// Declare all properties with validation
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Skeleton.propTypes = {
count: React.PropTypes.number.isRequired,
name: React.PropTypes.string.isRequired
};// Declare default properties
Counter.defaultProps = {
count: 0,
name : "Skeleton"
};export default App
----=== Property validator
This the list of validator available for properties :
[code, javascript]
----
optionalArray: React.PropTypes.array,
optionalBool: React.PropTypes.bool,
optionalFunc: React.PropTypes.func,
optionalNumber: React.PropTypes.number,
optionalObject: React.PropTypes.object,
optionalString: React.PropTypes.string,// Anything that can be rendered: numbers, strings, elements or an array
// (or fragment) containing these types.
optionalNode: React.PropTypes.node,// A React element.
optionalElement: React.PropTypes.element,// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
optionalMessage: React.PropTypes.instanceOf(Message),// You can ensure that your prop is limited to specific values by treating
// it as an enum.
optionalEnum: React.PropTypes.oneOf(['News', 'Photos']),// An object that could be one of many types
optionalUnion: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
React.PropTypes.instanceOf(Message)
]),// An array of a certain type
optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number),// An object with property values of a certain type
optionalObjectOf: React.PropTypes.objectOf(React.PropTypes.number),// An object taking on a particular shape
optionalObjectWithShape: React.PropTypes.shape({
color: React.PropTypes.string,
fontSize: React.PropTypes.number
}),// You can chain any of the above with `isRequired` to make sure a warning
// is shown if the prop isn't provided.
requiredFunc: React.PropTypes.func.isRequired,// A value of any data type
requiredAny: React.PropTypes.any.isRequired,
----=== Some links
* *React lifecycle :* https://busypeoples.github.io/post/react-component-lifecycle/