Code Monkey home page Code Monkey logo

react-demo's Introduction

Webix-React demo

This project was bootstrapped with Create React App.

You can use Webix inside of React App, to add some rich widgets to the existing functionality.

If you plan to use Webix for most UI in the app, please check Webix Jet first. It is a micro-framework for building Webix-based apps.

How to Start

Grab the demo from Github if you haven't done this yet. Thus you will get an example of integration usage.

Run npm install and npm start after that. Open http://localhost:3000 to view the demo in the browser.

The page will be reloading while you are editing form fields.

Production build

To build the production version, run npm run build.

It will build the application for production to the build folder. After that your app is ready to be deployed.

Using Webix Widget in React App

You can create a React component with a Webix widget inside like this:

const ui = {
	view:"slider"
};
const value = 123;

const SliderView = () => (
  <Webix ui={ui} data={value} />
)

The logic is the following:

  • use the tag < Webix > to define a Webix widget
  • specify the necessary view in the ui object and define its config

Creating Custom Webix-React Component

Instead of using a prebuilt Webix component, there is a possibility to make a custom one. For example, the code for a custom Slider component can look as follows:

class SliderView extends Component {
  render() {
    return (
      <div ref="root"></div>
    );
  }

  componentDidMount(){
    this.ui = webix.ui({
      view:"slider"
      container:ReactDOM.findDOMNode(this.refs.root)
    });
  }

  componentWillUnmount(){
    this.ui.destructor();
    this.ui = null;
  }

  shouldComponentUpdate(){
    return false;
  }
}

In the above code we have created the SliderView component that contains a Webix slider inside.

The list of the defined methods is:

  • the componentDidMount() method creates a new component
  • the componentWillUnmount() method will destruct the component when it won't be needed anymore
  • the shouldComponentUpdate() method is responsible for the component's updates. In this example, updates for the component are disabled

Using Webix Widget with Redux

You can use a Webix widget with Redux without any extra customization required.

For custom components make sure that such a component returns true from shouldComponentUpdate() and provides the componentWillUpdate handler to mutate the state of the Webix widget.

componentWillUpdate(props){
    if (props.data)
      this.setWebixData(props.data);
    if (props.select)
      this.select(props.select);
},
shouldComponentUpdate(){
	return true;
}

License

MIT

react-demo's People

Contributors

mafanya23 avatar mkozhukh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-demo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.