front end development (1)


Tips for making reusable React components

Tip 1: props.children const Picture = (props) => { return ( <div> <img src={props.src}/> {props.children} </div> ) } render () { return ( <div className=’container’> <Picture key={picture.id} src={picture.src}> //what is placed here is passed as props.children </Picture> </div> ) } Instead of invoking the component with a self-closing tag <Picture /> if you invoke it will full opening […]