Coder Social home page Coder Social logo

请教,关于传参的问题? about teaset HOT 4 CLOSED

rilyu avatar rilyu commented on September 17, 2024
请教,关于传参的问题?

from teaset.

Comments (4)

rilyu avatar rilyu commented on September 17, 2024

就按一般的RN组件传参方式就可以了,入参使用属性传入,返回参数使用回调函数传出,例:

this.navigator.push({view: <TestPage title='Test' onSubmit={value => this.onTestSubmit(value)}/>});

from teaset.

shaonq avatar shaonq commented on September 17, 2024
this.navigator.push({view: <AboutPage  testDate={{data:{user:"user",name:"name"}}} />})
constructor(props) {
        super(props);
        console.log(this.props.testDate);
 }

可以看到数据。

 componentDidMount() {
        this.interval = setInterval(() => {
            this.setState({
                timerCount: this._format(new Date())
            })
        }, 500)
    }
    componentWillUnmount() {
        clearInterval(this.interval)
    }

但是,模拟器放置一段时间后,报maximum call stack size exceeded

from teaset.

rilyu avatar rilyu commented on September 17, 2024

你在componentDidMount、componentWillUnmount加点日志看看这两个函数调用是不是成对出现,我记得从下层页面pop返回时会调用componentDidMount,但push时却不会调用componentWillUnmount,这样就会导致上一次的this.interval不会被clear,你加日志检查一下是不是这样

from teaset.

shaonq avatar shaonq commented on September 17, 2024

粗略的测试了一下,是成对出现,关于pop调用的问题,后续写代码的时候会留意。
目前的做法也是,

componentWillUnmount() {
        this.interval&&clearInterval(this.interval)
}

也猜测了 this.interval 未声明的问题;

var a={}   //Object {}
clearInterval(a.b)  //undefined

目前未出现错误。

from teaset.

Related Issues (20)

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.