Skip to content

A react compatible file library, supports submit form upload or download resource by iframe.

License

Notifications You must be signed in to change notification settings

afeiship/react-iframe-form

Repository files navigation

react-iframe-form

A react compatible file library, supports submit form upload or download resource by iframe.

properties:

  static propTypes = {
    className:PropTypes.string,
    encType:PropTypes.string,
    method:PropTypes.string,
    action:PropTypes.string,
  };

  static defaultProps = {
    encType:'multipart/form-data',
    method:'post',
    action:'/',
  };
  

usage:

// install: npm install afeiship/react-iframe-form --save
// import : import ReactIframeForm from 'react-iframe-form'

class App extends React.Component{
  state = {
    param1:'value1',
    param2:'value2-21313',
  };

  constructor(props){
    super(props);
    window.demo = this;
    window.refs = this.refs;
    window.rc = this.refs.rc;
  }


  _onClick =e =>{
    this.refs.rc.submit();
  };

  render(){
    return (
      <div className="hello-react-iframe-form">
        <button onClick={this._onClick}>Test submit</button>
        <ReactIframeForm ref='rc'>
          <input type="hidden" name="param1" value={this.state.param1}/>
          <input type="hidden" name="param2" value={this.state.param2}/>
        </ReactIframeForm>
      </div>
    );
  }
}

resource:

About

A react compatible file library, supports submit form upload or download resource by iframe.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published