Apply style to only one element of a map of elements












0















I am trying to imitate a behaviour of a checked componenet applied to a map of divs. I am mapping displayName and imageUrl of an array of elements called price. On click of the div, in handleProductSelect function, I would like only the clicked div to be highlighted, however they all become highlighted, which makes sense, because I am collectively making a change in the style.



class App extends Component {
constructor(props) {
super(props);

this.state = {
borderColor: 'white',
}
}


handleProductSelect() {
const { borderColor } = this.state;
let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
this.setState({
borderColor: newBorderColour,
})
}

(price.map(p =>
<div key={p.productId}>
<div
style={{
borderRadius: '10%',
borderStyle: 'solid',
padding: '10px',
marginBottom: 10,
borderColor: this.state.borderColor,
}}
onClick={this.handleProductSelect(p.productId)}>
<div>{p.displayName}</div><br />
<div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
</div>
</div>
))
}


Does anyone have any idea on how to make only the clicked element highlighted?










share|improve this question



























    0















    I am trying to imitate a behaviour of a checked componenet applied to a map of divs. I am mapping displayName and imageUrl of an array of elements called price. On click of the div, in handleProductSelect function, I would like only the clicked div to be highlighted, however they all become highlighted, which makes sense, because I am collectively making a change in the style.



    class App extends Component {
    constructor(props) {
    super(props);

    this.state = {
    borderColor: 'white',
    }
    }


    handleProductSelect() {
    const { borderColor } = this.state;
    let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
    this.setState({
    borderColor: newBorderColour,
    })
    }

    (price.map(p =>
    <div key={p.productId}>
    <div
    style={{
    borderRadius: '10%',
    borderStyle: 'solid',
    padding: '10px',
    marginBottom: 10,
    borderColor: this.state.borderColor,
    }}
    onClick={this.handleProductSelect(p.productId)}>
    <div>{p.displayName}</div><br />
    <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
    </div>
    </div>
    ))
    }


    Does anyone have any idea on how to make only the clicked element highlighted?










    share|improve this question

























      0












      0








      0








      I am trying to imitate a behaviour of a checked componenet applied to a map of divs. I am mapping displayName and imageUrl of an array of elements called price. On click of the div, in handleProductSelect function, I would like only the clicked div to be highlighted, however they all become highlighted, which makes sense, because I am collectively making a change in the style.



      class App extends Component {
      constructor(props) {
      super(props);

      this.state = {
      borderColor: 'white',
      }
      }


      handleProductSelect() {
      const { borderColor } = this.state;
      let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
      this.setState({
      borderColor: newBorderColour,
      })
      }

      (price.map(p =>
      <div key={p.productId}>
      <div
      style={{
      borderRadius: '10%',
      borderStyle: 'solid',
      padding: '10px',
      marginBottom: 10,
      borderColor: this.state.borderColor,
      }}
      onClick={this.handleProductSelect(p.productId)}>
      <div>{p.displayName}</div><br />
      <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
      </div>
      </div>
      ))
      }


      Does anyone have any idea on how to make only the clicked element highlighted?










      share|improve this question














      I am trying to imitate a behaviour of a checked componenet applied to a map of divs. I am mapping displayName and imageUrl of an array of elements called price. On click of the div, in handleProductSelect function, I would like only the clicked div to be highlighted, however they all become highlighted, which makes sense, because I am collectively making a change in the style.



      class App extends Component {
      constructor(props) {
      super(props);

      this.state = {
      borderColor: 'white',
      }
      }


      handleProductSelect() {
      const { borderColor } = this.state;
      let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
      this.setState({
      borderColor: newBorderColour,
      })
      }

      (price.map(p =>
      <div key={p.productId}>
      <div
      style={{
      borderRadius: '10%',
      borderStyle: 'solid',
      padding: '10px',
      marginBottom: 10,
      borderColor: this.state.borderColor,
      }}
      onClick={this.handleProductSelect(p.productId)}>
      <div>{p.displayName}</div><br />
      <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
      </div>
      </div>
      ))
      }


      Does anyone have any idea on how to make only the clicked element highlighted?







      javascript reactjs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 19:24









      kseniaksenia

      658




      658
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Use the id that you are passing to your handleProductSelect function and save it to the state. You can use it in the render method, to figure which one is the clicked element and apply the appropriate style to it



          class App extends Component {
          constructor(props) {
          super(props);

          this.state = {
          borderColor: 'white',
          active_id: null
          };
          }


          handleProductSelect(productId) {
          const { borderColor } = this.state;
          let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
          this.setState({
          borderColor: newBorderColour,
          active_id: productId
          })
          }

          render {
          return(
          (price.map(p =>
          <div key={p.productId}>
          <div
          style={{
          borderRadius: '10%',
          borderStyle: 'solid',
          padding: '10px',
          marginBottom: 10,
          borderColor: ( p.productId === this.state.active_id ? this.state.borderColor : 'white'),
          }}
          onClick={this.handleProductSelect.bind(this, p.productId)}>
          <div>{p.displayName}</div><br />
          <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
          </div>
          </div>
          ))
          }
          )}





          share|improve this answer


























          • thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

            – ksenia
            Nov 21 '18 at 19:43






          • 1





            WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

            – Velimir Tchatchevsky
            Nov 21 '18 at 19:44











          • thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

            – ksenia
            Nov 21 '18 at 19:53













          • You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:00






          • 1





            try that, you should pass this to the bind function

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:03



















          0














          Here I have fixes the syntax of ternary operator style css, and fatArrow function call with onClick event



          class App extends Component {
          constructor(props) {
          super(props);

          this.state = {
          borderColor: 'white',
          active_id: null
          };
          }


          handleProductSelect(productId) {
          const { borderColor } = this.state;
          let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
          this.setState({
          borderColor: newBorderColour,
          active_id: productId
          })
          }

          render {
          return(
          (price.map(p =>
          <div key={p.productId}>
          <div
          style={{
          borderRadius: '10%',
          borderStyle: 'solid',
          padding: '10px',
          marginBottom: 10,
          p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
          }}


          onClick={(p)=> this.handleProductSelect(p.productId)}>
          <div>{p.displayName}</div><br />
          <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
          </div>
          </div>
          ))
          }
          )}





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419221%2fapply-style-to-only-one-element-of-a-map-of-elements%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Use the id that you are passing to your handleProductSelect function and save it to the state. You can use it in the render method, to figure which one is the clicked element and apply the appropriate style to it



            class App extends Component {
            constructor(props) {
            super(props);

            this.state = {
            borderColor: 'white',
            active_id: null
            };
            }


            handleProductSelect(productId) {
            const { borderColor } = this.state;
            let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
            this.setState({
            borderColor: newBorderColour,
            active_id: productId
            })
            }

            render {
            return(
            (price.map(p =>
            <div key={p.productId}>
            <div
            style={{
            borderRadius: '10%',
            borderStyle: 'solid',
            padding: '10px',
            marginBottom: 10,
            borderColor: ( p.productId === this.state.active_id ? this.state.borderColor : 'white'),
            }}
            onClick={this.handleProductSelect.bind(this, p.productId)}>
            <div>{p.displayName}</div><br />
            <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
            </div>
            ))
            }
            )}





            share|improve this answer


























            • thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

              – ksenia
              Nov 21 '18 at 19:43






            • 1





              WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

              – Velimir Tchatchevsky
              Nov 21 '18 at 19:44











            • thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

              – ksenia
              Nov 21 '18 at 19:53













            • You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:00






            • 1





              try that, you should pass this to the bind function

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:03
















            1














            Use the id that you are passing to your handleProductSelect function and save it to the state. You can use it in the render method, to figure which one is the clicked element and apply the appropriate style to it



            class App extends Component {
            constructor(props) {
            super(props);

            this.state = {
            borderColor: 'white',
            active_id: null
            };
            }


            handleProductSelect(productId) {
            const { borderColor } = this.state;
            let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
            this.setState({
            borderColor: newBorderColour,
            active_id: productId
            })
            }

            render {
            return(
            (price.map(p =>
            <div key={p.productId}>
            <div
            style={{
            borderRadius: '10%',
            borderStyle: 'solid',
            padding: '10px',
            marginBottom: 10,
            borderColor: ( p.productId === this.state.active_id ? this.state.borderColor : 'white'),
            }}
            onClick={this.handleProductSelect.bind(this, p.productId)}>
            <div>{p.displayName}</div><br />
            <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
            </div>
            ))
            }
            )}





            share|improve this answer


























            • thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

              – ksenia
              Nov 21 '18 at 19:43






            • 1





              WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

              – Velimir Tchatchevsky
              Nov 21 '18 at 19:44











            • thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

              – ksenia
              Nov 21 '18 at 19:53













            • You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:00






            • 1





              try that, you should pass this to the bind function

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:03














            1












            1








            1







            Use the id that you are passing to your handleProductSelect function and save it to the state. You can use it in the render method, to figure which one is the clicked element and apply the appropriate style to it



            class App extends Component {
            constructor(props) {
            super(props);

            this.state = {
            borderColor: 'white',
            active_id: null
            };
            }


            handleProductSelect(productId) {
            const { borderColor } = this.state;
            let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
            this.setState({
            borderColor: newBorderColour,
            active_id: productId
            })
            }

            render {
            return(
            (price.map(p =>
            <div key={p.productId}>
            <div
            style={{
            borderRadius: '10%',
            borderStyle: 'solid',
            padding: '10px',
            marginBottom: 10,
            borderColor: ( p.productId === this.state.active_id ? this.state.borderColor : 'white'),
            }}
            onClick={this.handleProductSelect.bind(this, p.productId)}>
            <div>{p.displayName}</div><br />
            <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
            </div>
            ))
            }
            )}





            share|improve this answer















            Use the id that you are passing to your handleProductSelect function and save it to the state. You can use it in the render method, to figure which one is the clicked element and apply the appropriate style to it



            class App extends Component {
            constructor(props) {
            super(props);

            this.state = {
            borderColor: 'white',
            active_id: null
            };
            }


            handleProductSelect(productId) {
            const { borderColor } = this.state;
            let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
            this.setState({
            borderColor: newBorderColour,
            active_id: productId
            })
            }

            render {
            return(
            (price.map(p =>
            <div key={p.productId}>
            <div
            style={{
            borderRadius: '10%',
            borderStyle: 'solid',
            padding: '10px',
            marginBottom: 10,
            borderColor: ( p.productId === this.state.active_id ? this.state.borderColor : 'white'),
            }}
            onClick={this.handleProductSelect.bind(this, p.productId)}>
            <div>{p.displayName}</div><br />
            <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
            </div>
            ))
            }
            )}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 21 '18 at 20:00

























            answered Nov 21 '18 at 19:32









            Velimir TchatchevskyVelimir Tchatchevsky

            2,17411118




            2,17411118













            • thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

              – ksenia
              Nov 21 '18 at 19:43






            • 1





              WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

              – Velimir Tchatchevsky
              Nov 21 '18 at 19:44











            • thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

              – ksenia
              Nov 21 '18 at 19:53













            • You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:00






            • 1





              try that, you should pass this to the bind function

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:03



















            • thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

              – ksenia
              Nov 21 '18 at 19:43






            • 1





              WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

              – Velimir Tchatchevsky
              Nov 21 '18 at 19:44











            • thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

              – ksenia
              Nov 21 '18 at 19:53













            • You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:00






            • 1





              try that, you should pass this to the bind function

              – Velimir Tchatchevsky
              Nov 21 '18 at 20:03

















            thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

            – ksenia
            Nov 21 '18 at 19:43





            thank you, but this somehow send me into an infinite loop, with the following warning: react-dom.development.js:509 Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.

            – ksenia
            Nov 21 '18 at 19:43




            1




            1





            WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

            – Velimir Tchatchevsky
            Nov 21 '18 at 19:44





            WOW, I'm sorry for that, check the change. You shouldn't execute the function in onSubmit, which is what was happening

            – Velimir Tchatchevsky
            Nov 21 '18 at 19:44













            thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

            – ksenia
            Nov 21 '18 at 19:53







            thank you, I am getting another error inside handleProductSelect, Cannot read property 'borderColor' of undefined

            – ksenia
            Nov 21 '18 at 19:53















            You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:00





            You can also pass this to bind like so this.handleProductSelect.bind(this, p.productId)

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:00




            1




            1





            try that, you should pass this to the bind function

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:03





            try that, you should pass this to the bind function

            – Velimir Tchatchevsky
            Nov 21 '18 at 20:03













            0














            Here I have fixes the syntax of ternary operator style css, and fatArrow function call with onClick event



            class App extends Component {
            constructor(props) {
            super(props);

            this.state = {
            borderColor: 'white',
            active_id: null
            };
            }


            handleProductSelect(productId) {
            const { borderColor } = this.state;
            let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
            this.setState({
            borderColor: newBorderColour,
            active_id: productId
            })
            }

            render {
            return(
            (price.map(p =>
            <div key={p.productId}>
            <div
            style={{
            borderRadius: '10%',
            borderStyle: 'solid',
            padding: '10px',
            marginBottom: 10,
            p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
            }}


            onClick={(p)=> this.handleProductSelect(p.productId)}>
            <div>{p.displayName}</div><br />
            <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
            </div>
            </div>
            ))
            }
            )}





            share|improve this answer




























              0














              Here I have fixes the syntax of ternary operator style css, and fatArrow function call with onClick event



              class App extends Component {
              constructor(props) {
              super(props);

              this.state = {
              borderColor: 'white',
              active_id: null
              };
              }


              handleProductSelect(productId) {
              const { borderColor } = this.state;
              let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
              this.setState({
              borderColor: newBorderColour,
              active_id: productId
              })
              }

              render {
              return(
              (price.map(p =>
              <div key={p.productId}>
              <div
              style={{
              borderRadius: '10%',
              borderStyle: 'solid',
              padding: '10px',
              marginBottom: 10,
              p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
              }}


              onClick={(p)=> this.handleProductSelect(p.productId)}>
              <div>{p.displayName}</div><br />
              <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
              </div>
              </div>
              ))
              }
              )}





              share|improve this answer


























                0












                0








                0







                Here I have fixes the syntax of ternary operator style css, and fatArrow function call with onClick event



                class App extends Component {
                constructor(props) {
                super(props);

                this.state = {
                borderColor: 'white',
                active_id: null
                };
                }


                handleProductSelect(productId) {
                const { borderColor } = this.state;
                let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
                this.setState({
                borderColor: newBorderColour,
                active_id: productId
                })
                }

                render {
                return(
                (price.map(p =>
                <div key={p.productId}>
                <div
                style={{
                borderRadius: '10%',
                borderStyle: 'solid',
                padding: '10px',
                marginBottom: 10,
                p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
                }}


                onClick={(p)=> this.handleProductSelect(p.productId)}>
                <div>{p.displayName}</div><br />
                <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
                </div>
                </div>
                ))
                }
                )}





                share|improve this answer













                Here I have fixes the syntax of ternary operator style css, and fatArrow function call with onClick event



                class App extends Component {
                constructor(props) {
                super(props);

                this.state = {
                borderColor: 'white',
                active_id: null
                };
                }


                handleProductSelect(productId) {
                const { borderColor } = this.state;
                let newBorderColour = borderColor === 'white' ? 'blue' : 'white';
                this.setState({
                borderColor: newBorderColour,
                active_id: productId
                })
                }

                render {
                return(
                (price.map(p =>
                <div key={p.productId}>
                <div
                style={{
                borderRadius: '10%',
                borderStyle: 'solid',
                padding: '10px',
                marginBottom: 10,
                p.productId === this.state.active_id ? { borderColor: this.state.borderColor} : {borderColor : 'white'}
                }}


                onClick={(p)=> this.handleProductSelect(p.productId)}>
                <div>{p.displayName}</div><br />
                <div>{p.imageUrl !== '' ? p.imageUrl : <img style={{ width: '100px', height: '50px' }} src={"https://source.unsplash.com/200/150"} />}</div><br />
                </div>
                </div>
                ))
                }
                )}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 13:02









                Anupam MauryaAnupam Maurya

                1369




                1369






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419221%2fapply-style-to-only-one-element-of-a-map-of-elements%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith