Home >Web Front-end >JS Tutorial >Use a very simple example to understand the idea of ​​react.js high-order components

Use a very simple example to understand the idea of ​​react.js high-order components

一个新手
一个新手Original
2017-10-06 10:42:151583browse

Before debugging the code, I set up two caches

They are username and content

set in the console Two cache codes

localStorage.setItem('username','老王')
localStorage.setItem('content','类容')

Be sure to set these two caches before running the following code, because I encapsulated the public method in the high-order component and called the cache to the value of the input box

, the component returned by the higher-order component calls this method

'react''react-dom'.state={data:''==(event)=>=
            <Comp handBlur={.handBlur} data={.state.data}/> <input type="text" defaultValue={props.data} onBlur={props.handBlur}/> <textarea defaultValue={props.data}></textarea> <p>111</p>let LocalInput=local(Input,&#39;username&#39;=local(Textareas,&#39;content&#39;=<p>
                <form><LocalInput/>
                    类容 <LocalTextareas/>
                    <Localp></Localp>
                </form>
            </p><From></From>,document.querySelector("#root"))

The above is the detailed content of Use a very simple example to understand the idea of ​​react.js high-order components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn